如果你的数据里面有
\n
或者诸如此类的字符或字符串想替换掉
用String.replaceAll
就可以了String text = jTextPane1.getText();
text = text.replaceAll( "\n", " " );其他的替换于此相差不远
\n
或者诸如此类的字符或字符串想替换掉
用String.replaceAll
就可以了String text = jTextPane1.getText();
text = text.replaceAll( "\n", " " );其他的替换于此相差不远
我的代码:
String text = jTextPane1.getText();
text = text.replaceAll( "\n", " " );
System.out.println(text);
eclipse编译
输入
acbdefg
aaaaaa
bbbbbb
ccccccc
输出:
acbdefg
aaaaaa
bbbbbb
ccccccc
text = text.replaceAll( "\r", "" );
text = text.replaceAll( "\n", " " );