• Post Reply Bookmark Topic Watch Topic
  • New Topic

notepad issue

 
ajse ruku
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I am wring string to txt file using

FileOutputStream fileOutputStream=new FileOutputStream("D:/test.txt");
BufferedWriter out =new BufferedWriter(new OutputStreamWriter(fileOutputStream,"UTF-8"));
out.write(text);

If i open the file in wordpad,its fine but when i open it on notepad ,its not showing text in proper format.There is no "\n" shown.All the data is shown in one line.There is no line breal etc.

Please help to resolve this issue.

regards,
ajse
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wordpad handles non-Windows end-of-line indicators gracefully. Notepad does not. If you want your file to be readable in Notepad, you will have to use Windows EOL markers "\r\n" or, the system-independent way:
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also note that Notepad requires a Byte Order Mark at the start of the UTF-8 (or UTF-16) file. You will need to write this first:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!