I am writing to a text file in a while loop:
BufferedWriter writer = new BufferedWriter("...");
BufferedReader reader = new BufferedReader("...");
while((line = reader.readline()) != null){
....
writer.write(line + "\n");
}
reader.close();
writer.close();
This code doesn't write the line to the file as soon as each line is processed. I want the line to be written into the file in each iteration. How to achieve that?