简体   繁体   中英

Removing null value line in “.dat” file when using PrintWriter

Anyone know how to remove null value line in ".dat" file when I create file using PrintWriter ? Why does the file just print a null line in the last page of line, I already put:

PrintWriter outputFile = new PrintWriter(new FileWriter(File file));

then after I do process .. I put:

outputFile.flush();
outputFile.close();

But null is still printing on the last line. When I try to save the file in .txt format, there is no null line. but I need to save as a ".Dat" file.

Suffix doesn't matter for a file, so there should be no difference between these two files. The null value you saw in .Dat file is maybe a place-holder for editor that you opened the file with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM