I want to take data from the user like Stringand replace the newline character \nwith,
I tried:
String test ="s1\ns2\ns3\ns4";
System.out.println(test.replaceAll("\n",","));
The output was s1, s2, s3, s4
But when I try to use the same code, getting input from the user interface, it does not work.
When I debug it, the string test (which I am hard-coded) is processed as
s1
s2
s3
s4
but the string from the UI is " s1\ns2\ns3\ns4".
Please suggest what is wrong.
source
share