KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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.replace("\n", ""); but this doesn't seem to work. How can this be done?
Tags (comma-separated)
Save Edits
Cancel