Hi
I have a problem with a multi-line text, to be converted to one line, which I take from a JEditorPane.
I tried several things but it is still multi line
// the text is taken from JEditorPane
String str = jeditorPane.getText();
// replace "\n" with " "
str.replaceAll("\\n", " ");
or
// the text is taken from JEditorPane
String str = jeditorPane.getText();
Scanner s = new Scanner(str);
String line;
String completeText="";
while( ( line = str.nextLine() ) != null ){
completeText += line + " ";
}
In the fist code, it replaces all the "\n"'s with a space but it is still multi-line
in the second one, it doesn't change anything
So, what is wrong with these codes?
p.s. In the second code there (may) be a little mistake causing compile time error, please ignore that, my problem is with the logic of the code
thanks