• Post Reply Bookmark Topic Watch Topic
  • New Topic

regarding StringBuffer  RSS feed

 
tadi raja
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a doubt in StringBuffer.i want to break the line in StringBuffer
i am using System.getProperty(line.separator) to new line its not working in StringBuffer it says 'null' instead of new line and also sb.append("\n")is also not working.
 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understood your question correctly, then following code works:


Output is

Using backslash n
hello
world
Using line.separator
hello
world
 
Campbell Ritchie
Marshal
Posts: 56576
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always use line.separator if you can.

The most likely explanation is that there was a tiny spelling error in what you were submitting first time.
You know you can get an array of properties from a method in the System class, then you can go through them and get the correct spelling, preferably with copy-and-paste.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!