Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

\r does not generate a line break

Tags:

java

string

I use the following code:

if (delanaloge.equals(stari)) {
    if (novi.equals("-")) {
           zdruzen = " -";
    } else {
       zdruzen = zdruzen + " " + " - " + novi + "\r";
    }
    nap = true;
 } 

\r is appended to create a line break, but it does not generate a line break like I expect. I would like to generate an output similar to this:

- 213
- 232
- 1321

How can I add a line break in my string?

like image 369
senzacionale Avatar asked Feb 01 '12 09:02

senzacionale


People also ask

How do you break a line in R markdown?

To break a line in R Markdown and have it appear in your output, use two trailing spaces and then hit return .

How do I print a line break in R?

To use a tab separator, use "\t", and use "\n" to create a line break.

How do I move text to the next line in R?

Shift + Enter in the Console to move to a new line.

How do you add a line break in Java?

In Windows, a new line is denoted using “\r\n”, sometimes called a Carriage Return and Line Feed, or CRLF. Adding a new line in Java is as simple as including “\n” , “\r”, or “\r\n” at the end of our string.


1 Answers

you could use this:

public static String newline = System.getProperty("line.separator");
like image 199
wuppi Avatar answered Sep 20 '22 15:09

wuppi