how to read input from a text file in java code example
Example: java how to read a text file
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
class Scratch{
public static void main(String[] args) throws FileNotFoundException {
Scanner input = new Scanner(new File("filename"));
input.next(); //returns next String
input.nextLine(); //returns next Line
input.nextBoolean();//returns next Boolean
input.nextInt(); //returns next Int
input.nextDouble(); //returns next double
...
}
}