Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Extra Characters at the end of each line  RSS feed

Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!