jQuery in Action, 3rd edition
The moose likes I/O and Streams and the fly likes Extra Characters at the end of each line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Extra Characters at the end of each line" Watch "Extra Characters at the end of each line" New topic

Extra Characters at the end of each line

Joe Lemmer
Ranch Hand

Joined: Oct 24, 2008
Posts: 171
Hi there,

I am experimenting with using the basic IO classes needed for the SCJP exam. I am trying to read the contents of one file using FileReader and BufferedReader, and then write this to another file using PrintWriter. However, whether I use the println() or the print() method of PrintWriter, I am getting extra characters at the end of each line. They are showing up in notepad++ as square boxes when I use println() and little null graphics when I use print(). I have tried a basic text editor like plain notepad and it's the same story there.

I have googled and think it might have something to do with an extra '\n' character when I use println. If this is the case though I would have thought that there would simply be an extra space between all the lines. Also, when I use the print method, there are no line breaks at all in the target file.

Can anybody help?

Here is my code:

Many thanks


I agree. Here's the link: http://aspose.com/file-tools
subject: Extra Characters at the end of each line
It's not a secret anymore!