It's all about the answers!

Ask a question

Unable to print line space between 2 string values


Mahesh Vasamsetti (176) | asked Aug 03 '15, 1:46 a.m.
StringBuilder ac = new StringBuilder();
ac = ac.append(cu.getFieldText("Text1"));
ac = ac.append("\n");
ac = ac.append(cu.getFieldText("Text2"));
ac = ac.append("\n");

When i am passing ac.toString() value to the another textArea the values are printing on the same row instead of printing like below

abc
<<line space>>
efg

Tried with below:
1. ac.append("\n");
2. ac.append("\r\n");
3. ac.append(System.getProperty("line.separator"));

above 3 ways are working fine and printing the correct out put on the console but printing all the text in the same line when passed it to the text area. Please help me.

Accepted answer


permanent link
Donald Nong (14.5k414) | answered Aug 03 '15, 10:03 p.m.
edited Aug 03 '15, 10:03 p.m.
If you mean an HTML presentation when using the term "text area", you need to use the tag < br > for a new line.
Mahesh Vasamsetti selected this answer as the correct answer

Comments
Mahesh Vasamsetti commented Aug 04 '15, 8:12 a.m.

  ac = ac.append("<br>"+cu.getFieldText("Text1")+"</br>");

 ac = ac.append("<br>"+cu.getFieldText("Text2")+"</br>");

This is working for me. Thnx

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.