I have this code to read numbers (type double) from a text file to a list.
ArrayList listTest = new ArrayList();
try {
FileInputStream fis = new FileInputStream(path);
InputStreamReader isr = new InputStreamReader(fis, "UTF-16");
int c;
while ((c = isr.read()) != -1) {
listTest.add((char) c);
}
System.out.println();
isr.close();
} catch (IOException e) {
System.out.println("There is IOException!");
}
However, the output is look like:
1
1
.
1
4
7
4
2
.
8
1
7
3
5
instead of
11.147
42.81735
How can add the number to list line by line?