Note that there are some explanatory texts on larger screens.

plurals
  1. POReading in a text file into a collection isue
    primarykey
    data
    text
    <p>I have a text file which has the following structure inside it: </p> <pre><code>Daily Rainfall Totals (mm), Weather Station,(Meteorological Office Climatological Station TY12SDF) John Smith, DRE, RED Division, data obtained DEC 2011 Format=Year, Month, 1-31 daily precipitation values. Any entry set to -99.99 means that no data exists for that day. 2010 1 1.10 5.50 0.00 7.80 1.80 0.00 0.00 0.00 0.00 0.70 0.70 0.01 0.60 2.40 14.30 1.00 0.30 1.20 0.00 0.00 9.90 0.30 1.10 0.40 0.01 0.20 0.10 2.00 0.00 0.00 0.00 2010 2 10.40 0.00 3.00 0.90 0.00 0.30 0.01 0.00 0.00 0.00 0.00 0.10 0.00 1.00 10.00 3.30 0.10 2.90 0.00 0.01 0.01 0.00 5.20 0.01 9.90 9.00 0.00 0.01 -99.99 -99.99 -99.99 2010 3 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.10 0.00 2.20 9.00 4.70 2.00 2.50 4.10 0.90 11.10 3.90 0.01 0.30 5.60 17.40 0.30 </code></pre> <p>I would like to read the values into a collection but i dont know which one i should use? This is because i intend to bind each of the years data into a GUI control.</p> <p>I know how to read in a comma delimited data 1,2,3 like this:</p> <pre><code>File file = new File("sample.txt"); ArrayList&lt;String&gt; num = new ArrayList&lt;String&gt;(); Scanner in = new Scanner(file); while (in.hasNextLine()){ num.add(in.nextLine()); } </code></pre> <p>EDIT But the problem is I would like to create a structure in the collection which will look like this after I have read in the file: [2010] [1] [2.2, 2.3, 2.4, 2.5] Where 2010 is the year, 1 is the month and the rest is the data.</p> <p>How would I go about achieving this? Multidimensional array?</p> <p>Thanks,</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload