I am reading a file with one paragraph at a time seperated by a newline.
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Here I read Lines 1, 2, 3 and then Lines 4, 5, 6.
while (there are still more paragraphs) {
String paragraph = new Scanner(new File("testdata.txt")).useDelimiter("\n\n").next();
}
The delimeter "\n\n" is to identify paragraph and not a line. Now, the delimiter can change into "\r\n\r\n" in few systems and "\n\n" in other few. Is there any way to identify it at runtine and use it? I am looking for something like:
String delimiter = getNewLineCharYourself();
String paragraph = new Scanner(new File("testdata.txt")).useDelimiter(delimiter).next();