In this article, we will see how to read input from a file with Scanner class and read without loop in Java.
Scanner is a class in java.util package used for read input of the primitive types like int, double, etc. and string s. It is easier way to read input.
Lets look to our code.
File f1 = new File("...filepath...");
Scanner sc1 = new Scanner(f1);
Lets see it in an example.
In above example, we created a scanner class object and read from it to print to output.