如何使用StringBuffer附加\n字面意思?

kof*_*cii 2 java

如何追加"\n",从字面上看,不像特殊字符.

我不会这样做:

StringBuffer st = new StringBuffer;

st.append(text1);
st.append("\n");
st.append(text2);
Run Code Online (Sandbox Code Playgroud)

和输出字符串:

text1 \n text2
Run Code Online (Sandbox Code Playgroud)

text1
text2
Run Code Online (Sandbox Code Playgroud)

Emi*_*mil 13

StringBuffer st = new StringBuffer();
st.append("Hello");
st.append("\\n"); //<- the first \ escapes the second
st.append("World");
Run Code Online (Sandbox Code Playgroud)