PrintWriter outputStream = new PrintWriter(new FileWriter(filenameOut));
BufferedReader inputStream = new BufferedReader(new FileReader(filenameIn));
I create a PrinterWriter like so, then I read a line of text from a text file using a BufferedReader wrapped around a FileReader. Each line of text is read by BufferedReader's readLine() method. And each line is written using the PrintWriter's println() method.
The weird behaviour occured while running my application twice, the first iteration and second iteration output different Strings to a text file, using the same println() method of PrintWriter and each String not containing a newline character. The lengths of the two files differed, one was off by 10 lines after reading in 50 thousand lines. It took me twenty minutes to plug in flush() after every invocationg of the println() method from PrintWriter to resolve the issue. Both the PrintWriter and BufferedReader were closed after processing.
Any possible explanations for this? I assume it's not a bug but my own personal misuse.
Mel