$Hi/\bEr
Phil
Shiaber Shaam wrote:Hi,
Please check the below snippet.
String problemNotes = new String();
problemNotes = "Date: "+childElement.getAttributeValue("date")+"\n"+"Submitter: "+childElement.getAttributeValue("submitter")+"\n"+"Notes: "+childElement.getText();
But i am not getting a new line at all.
Please help.
[ July 10, 2008: Message edited by: Shiaber Shaam ]

Where did you get that from? You cannot insert anything into a String that wasn't there from the beginning, because Strings are immutable. You would have to include the \n when the String was first created. If you want to insert something, it is probably best to use a StringBuilder object. As people have said, the behaviour is platform‑dependent, which is why I don't like to use plain simple \n and \r. It is probably also not strictly defined, which means that it might have changed in the 17½ years since this thread was started.Kamalika Seenivasan wrote:A new line character can be inserted in a string . . .
Campbell Ritchie wrote:You would have to include the \n when the String was first created.
The problem with getting rid of the "undesirables" is that sooner or later someone will decide that YOU are an undesirable.
Nor would I, unless somebody tells me they want CR‑LF and they want me to tell them what line end I am using.Tim Holloway wrote:. . . I would NOT put OS-dependent line terminators (such as CR-LF) in Strings. . . .
The problem with getting rid of the "undesirables" is that sooner or later someone will decide that YOU are an undesirable.
Don't remind me of that dreadful machineTim Holloway wrote:. . . a recycled Teletype[TM} machine . . .

That is correct; I think they changed to plain simple LF when they introduced OS/X.one time, Apple had been using CR without LF as a line terminator. . . .
No, there is no such thing as the correct newline character. Nor is there a character called “new line.” That is the “linefeed” character, often called LF. You read \n in code (as Tim H said) as, “newline.”Vaeshnavi Subbiah wrote:. . . \n is the correct newline escape sequence. . . .
Campbell Ritchie wrote:
No, there is no such thing as the correct newline character. Nor is there a character called “new line.” That is the “linefeed” character, often called LF. You read \n in code (as Tim H said) as, “newline.”Vaeshnavi Subbiah wrote:. . . \n is the correct newline escape sequence. . . .
We have seen already that different operating systems use different line ends. Fortunately most programs nowadays are able to use LF on its own, so there is usually no problem visible to the end‑luser.
The problem with getting rid of the "undesirables" is that sooner or later someone will decide that YOU are an undesirable.
| Consider Paul's rocket mass heater. |