I am using Java BufferedWriter to write to a file line by line. The problem is that when I finish writing the file it shows “nul” all over the file.
I do not think the problems is with what I am writing because I double check it with System.out.print and it gives me the desired output.
Any help?
The problem is either with what you are writing, or you are forgetting to close the file after writing to it (and it already contains nul from a previous write). If you check the data you’re writing with
System.out.print, then I suppose it’s the latter. Make sure you callclose()on your file before your program exits.