Here's my code so far, as I understand it it doesn't succeed reading in the numbers,
I have a txt file which is tab delimited, in 3 columns and a lot of rows, e.g
1 23 343
2 34 355
3 31 435
...
etc.
...
So, i want to read in every number from the txt file into 3 different Array lists.
import java.util.ArrayList; import java.io.FileReader; import java.io.FileNotFoundException; import java.io.BufferedReader; import java.io.IOException; public class dataIn { public void readFile() { String line = null; ArrayList[] chData = new ArrayList[3]; try { FileReader fr = new FileReader("ch.txt"); BufferedReader br = new BufferedReader(fr); while((line = br.readLine()) != null) { String[] theLine = line.split("\\t"); chlData[0].add(Double.parseDouble(theLine[0])); chlData[1].add(Double.parseDouble(theLine[1])); chlData[2].add(Double.parseDouble(theLine[2])); } } catch(FileNotFoundException fN) { fN.printStackTrace(); } catch(IOException e) { System.out.println(e); } } }
Thanks in advance.