• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

notepad issue

 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
reply
    Bookmark Topic Watch Topic
  • New Topic