Using a scanner to read a file

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();
+4
source share
1 answer

Save the jsp file as .txt and try to read it using your first method. if it works, I feel that size can be a problem.

0
source

All Articles