One hell of a long question :)
Here's how I usually do it:
StringBuilder b = new StringBuilder();
BufferedReader r = new BufferedReader(new StringReader(s));
while ((String line = r.readLine()) != null)
b.append(doSomethingToTheString(s) + "\n");
However, this replaces all the new line characters in the file with a line feed, plus it adds one at the end if there wasn't one. What I want is to preserve EOL characters, even if it's mixed up like this:
Hello\r\n
World\n
This is\r
Messed up
What would be the most elegant/efficient way to do this?