Escape Description ASCII-Value \n New Line Feed (LF) 10 \r Carriage Return (CR) 13
So you need to try string.split("\n\r")
in your case.
Edit
If you want to split an empty string, try \n\r\n\r
. Or you can use .readLine()
to read your file and skip all empty lines.
Are you sure this is 10 13 10 13
? It should always be 13 10
...
And you should not depend heavily on line.separator
. Because if you are processing some files from the * nix platform, it \n
is the other way around. And even on Windows, some editors use \n
as the newline character. Therefore, I suggest you use some high-level methods or use string.replaceAll("\r\n", "\n")
to normalize the input.
source share