I write to a text file using BufferedWriter, but BufferedWriter does not write the file until the program that I run is finished, and I am not sure how to update it, since BufferedWriter supposedly writes. Here are some of my codes that I have:
FileWriter fw = null;
try {
fw = new FileWriter("C:/.../" + target + ".pscr",true);
writer = new BufferedWriter(fw);
writer.write(target);
writer.newLine();
writer.write(Integer.toString(listOfFiles.length));
writer.newLine();
for(int i=0; i < listOfFiles.length; i++){
writer.write(probeArray[i] + "\t" + probeScoreArray[i]);
writer.newLine();
}
}
catch (IOException e1) {e1.printStackTrace();}
catch (RuntimeException r1) {r1.printStackTrace();}
finally {
try {
if(writer != null){
writer.flush();
writer.close();
}
}
catch (IOException e2) {e2.printStackTrace();}
}
I am doing a BufferedWriter reset, but I still don't have the file as soon as it is written, but instead, when the program ends. Any suggestions?
source
share