Reading Text file to Data type Double
Hi All,
I am currently working on a file which will read a text file which contains data for an array, and then uses that data to create a plot.
My issue is that while I am able to read the text file and store the data as a string, I am finding it difficult to convert this string to a Double [][] array to be used in the plotting.
Here's the section of code I'm using to hopefully accomplish this:
try{
File textfile1 = new File("/Users/malkaysi/Downloads/test2.txt");
FileReader fileReader = new FileReader(textfile1);
BufferedReader reader = new BufferedReader(fileReader);
String line = null;
while((line = reader.readLine()) !=null) {
// System.out.println(line);
// This is where I am trying to convert the string to the double array, however there is no output..
double data = Double.parseDouble(line);
System.out.println(data);
}
reader.close();
} catch (Exception ex) {
}
Thanks!