I have the following code already, which goes as far as appending the doubles.
Scanner sc1 = new Scanner(System.in);
try {
System.out.println("Enter filename:");
String name = sc1.nextLine();//determines name of file
File file = new File(name);//creates above file
FileReader fileReader = new FileReader(file);//file is read
BufferedReader bufferedReader = new BufferedReader(fileReader );//BufferReader reads file, line by line
StringBuffer stringBuffer = new StringBuffer();//appended to StringBuffer
String line;//reads each
while ((line = bufferedReader.readLine()) != null)
{
stringBuffer.append(line + "\n");
}
fileReader.close();
System.out.println("Contents of file:");
System.out.println(stringBuffer.toString());
}
catch (IOException e)
{
e.printStackTrace();
}
The code reads a file that has a double on each line
ex:
1
2
3
4
5
...
How do I store each of these doubles into an array?