How do I read file using Scanner class?

Share:

Here is a compact way to read file line-by-line using the java.util.Scanner class.