how to make multiple line string to single line string?
No regular expressions and operating system independent:
str1.replaceAll(System.lineSeparator(), " ");
Windows uses \r\n as a line breaker, while *nix systems use only \n.
Use String.replaceAll
instead.
str1=str.replaceAll("[\r\n]+", " ");
If you want to use regex, you should use the String.replaceAll()
method.