Henry Wong wrote:
Use this...instead of using the system property. Unix uses a line feed as the separator, while windows uses the carriage return and line feed combination. This is not normally an issue because the Java println code does a good job and accounting for the difference. The regex stuff doesn't account for this, so it will need to be correct.
Hm, not sure I agree. Java is supposed to be platform-independent, and the above will only
work for a string produced by Unix. However
str = str.replaceAll("\r?\n", " ");
should work for one from any OS.
The problem with System.getProperty("line.separator")
is that it returns the separator for the system being run on
, not the one that produced the string.