How can I replace all line breaks from a string in Java in such a way that will work on Windows and Linux (ie no OS specific problems of carriage return/line feed/new line etc.)?
I've tried (note readFileAsString is a function that reads a text file into a String):
String text = readFileAsString("textfile.txt");
text = text.replace("\n", "");
but this doesn't seem to work.
How can this be done?
I want to remove ALL line breaks from the file as the resulting file will then be used by another part of the program.