previous
|
start
|
next
Reading Text Files
Simplest way to read text: use
Scanner
class
To read from a disk file, construct a
FileReader
Then, use the
FileReader
to construct a
Scanner
object
FileReader reader = new FileReader("input.txt"); Scanner in = new Scanner(reader);
Use the
Scanner
methods to read data from file
next
,
nextLine
,
nextInt
, and
nextDouble
previous
|
start
|
next