<<< BufferedReader, reading delimited text file | Index | A subset of the IOException hierarchy >>> |
The Scanner class can be used for formatted input from a character file:
Scanner inFile = new Scanner( new FileReader( "myfile.dat" ) );
To input data, call next(), nextInt(), nextDouble(), and so on:
String firstName; String lastName; double hoursWorked; double payRate; double wages; firstName = inFile.next(); lastName = inFile.next(); hoursWorked = inFile.nextDouble(); payRate = inFile.nextDouble(); wages = hoursWorked * payRate; inFile.close(); //close the input file
<<< BufferedReader, reading delimited text file | Index | A subset of the IOException hierarchy >>> |