Yes. In fact, this is what is done with input redirection.
With file input redirection, a disk file is connected to the
standard input stream used by a
You can also construct a scanner object that connects to
a disk file:
File file = new File("myData.txt"); // create a File object Scanner scan = new Scanner( file ); // connect a Scanner to the file
These statements first create a
This is a software object that represents a disk file.
Scanner object is constructed and connected
to the actual file.
The same methods can be used with this
as with standard input.
Characters than can be converted into an
int can be scanned in
nextInt() as with the standard input stream.
Must the disk file that is used with
Scanner be a text file?