I was looking into a problem with .close()
causing cut-off issues. The program is running on two different servers, but had the same cutoff issue. It appears that the log file is not flushing properly. So I decided to dig into the .close()
source code. I don't see a .flush()
being called. Am I missing something? Should we always call .flush()
? According to this answer, it shouldn't matter: Using flush() before close()
What I'm calling:
private static void write_to_file(String incoming){
output_stream.write(incoming);
output_stream.write(System.lineSeparator());
}
Later on I call output_stream.close();
The source code:
/**
* Closes the stream and releases any system resources associated
* with it. Closing a previously closed stream has no effect.
*
* @see #checkError()
*/
public void close() {
try {
synchronized (lock) {
if (out == null)
return;
out.close();
out = null;
}
}
catch (IOException x) {
trouble = true;
}
}
Log file:
C:\apps\bot\log\processed\file.0000090.gz C:\apps\bot\log\processed\file.0000091.gz C:\apps\bot\log\process