How to split string with empty new line
java, string
Solution
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 by empty line, try `\n\r\n\r`. Or you can use `.readLine()` to read your file, and skip all empty lines.
Are you sure it's `10 13 10 13`? It always should be `13 10`...
And, you should not depend on `line.separator` too much. Because if you are processing some files from *nix platform, it's `\n`, vice versa. And even on Windows, some editors use `\n` as the new line character. So I suggest you to use some high level methods or use `string.replaceAll("\r\n", "\n")` to normalize your input.
Problem
my file contains this string: ``` a b c ``` now I want to read it and split it with empty line so I have this: ``` text.split("\n\n"); where text is output of file ``` problem is that this doesnt work. When I convert new line to byte I see that "\n\n" is represented as 10 10 but new line in my file is represented by 10 13 10 13. So how I can split my file ?