How to Replace newline character ‘\n’ by blank in java

Below is the 2 line code for replacing “\n” from any string in JAVA.

st = "username\n\n\n"
st=st.trim();
st=st.replace("\n", "");
System.out.println(st);

Output

username

Posted in Uncategorized

4 thoughts on “How to Replace newline character ‘\n’ by blank in java

  1. A person necessarily help to make significantly posts I would state.
    That is the very first time I frequented your web page and thus
    far? I surprised with the research you made to make this particular
    put up amazing. Magnificent job!

Leave a Reply to bit.ly Cancel reply

Your email address will not be published.

Verified by MonsterInsights