I have tried using string.split("\n\n") but it does not work. Anyone has any solution? thanks in advance
3 Answers
First of all you should escape the \ with another \ like this:
string.split("\\n\\n"); Another way is using system default line separator:
string.split(System.getProperty("line.separator")+"{2}"); or you can try mix this:
string.split("(\\r\\n|"+System.getProperty("line.separator")+")+"); split need RegExp, so you can try variants for your problem.
And don't forget that sometimes new line is not only \n symbol, for Windows files it can be \r\n char sequence.
1 Comment
Blake Neal
Three years later. So helpful!