In the past, I found the following useful for reading in text files:
new Scanner(file).useDelimiter("\\Z").next();
However, today I came across a file that was only partially read using this syntax. I'm not sure what makes this file special, it's just .jsp
I found that this example works below, but I would like to know why the previous method did not work.
Scanner in = new Scanner(new FileReader(file));
String text = in.useDelimiter("\\Z").next();
source
share