I have a program that should read from a file.It reads some amount of data but not all.When i try to read the same file at the same location with another program done in the same manner with the same classes it reads the entire file.
Here is the code used in both programs:
if (i >= 1) {
try {
file = new File("Tabel " + i + " " + timeLine + ".csv");
fw = new FileWriter(file);
fw.write(FileChooserSave.getInstance().getStringArray()[i]);
if (i == 1) {
FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis,"UTF-8");
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
fis.close();
isr.close();
br.close();
}
} catch (IOException ex) {
Logger.getLogger(Frame.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
fw.close();
} catch (IOException ex) {
Logger.getLogger(Frame.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
It always stops reading in the same place.I checked to see if there is some ackward character but there isn’t.
I should also mention that the file from which i read is in the .csv format and is a pretty big one, but i don’ see if that is the problem.
Thanks in advance!
You are reading the file while the FileWriter is still open. This can lead to not having all the writes flushed to disk.
Try to move the call to close before new FileInputStream.