Scanner class
In fact, we are more commonly used to use the scanner class to enter data, the following to give a scanner example bar
import java.util.scanner;
/** * scanner Small example, reading data from the keyboard * */ public class scannerdemo{ public static void mai N (String[] args) {         SCANNER SCA = NEW&N Bsp Scanner (system.in); // read an integer     &NBS P; int temp = sca.nextint ();         SYSTEM.OUT.PRINTLN (temp); //Read floating-point numbers &nbs P; float flo=sca.nextfloat ();         SYSTEM.OUT.PRINTLN (FLO);   &NBSp; //read characters //... And so on, are some too basic, it is not normal.
} }
In fact, scanner can accept any input stream
Here's a read from a file using the scanner class
Import Java.io.File;
import java.io.FileNotFoundException;
import Java.util.Scanner;
/**
* Scanner Small example, read from file
* *
/public class scannerdemo{public
static void main (S Tring[] args {
file File = new File ("D:" + File.separator + "Hello.txt");