I am writing a network app for Android. According to the protocol specification, the end of each line must be a CR/LF combination. While I have no problem with generating this with my own strings, there are times that I will have to process user input and convert the line end.
It doesn’t matter what I store the EOL as internally, as long as it gets sent over the wire as CR/LF; if the easiest way is to change it as it goes to the network, that’s OK.
What is an easy and efficient way to ensure that all my network output ends with CR/LF, no matter what my string is in memory?
Normally when you read lines of text, it doesn’t include the original EOL characters
When you write the lines, write the EOL character(s) you want instead of using something like
printlnIf you have a String in memory which contains unknown EOL characters you can use