Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to insert new line character in string  RSS feed

 
Ritu Pande
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am having some problem. Java program creates string with new lines in it and save this in txt file. While reading the txt file in notepade I am not able to break the string in new lines ( I tried \n ).

Any ideas ?

Thanks in advance

Ritu
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean in Notepad there are no line breaks? Notepad being a Windows program it is probably looking for Windows linebreaks, which are "\r\n", not just "\n". There's also a system property called "line.separator" where this is stored.
Additional benefit of using the property instead of hard-coding the string is that you can move the program to a different platform, and it will then use the line terminator for that platform, instead of the Windows one.
[ August 04, 2005: Message edited by: Ulf Dittmer ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!