← Skill tree CS Skill Tree 0 CSCD210

Reading Files with Scanner and the hasNext Cascade

Textbook: BJP Ch 6

Where you are: Week 0 review > Reading files

This part of the review is two short lessons. Work them in order:

  1. Reading a file with Scanner: the path object versus the open file, the cursor model, and closing the file.
  2. Tokens, lines, and the hasNext cascade: line mode versus token mode, matching the guard to the read, and the nextInt-then-nextLine trap.

Finish both before moving on to classes, encapsulation, and equals and hashCode.


Resources

Canonical: BJP (Reges and Stepp) §3.3 (Scanner objects), Ch 6 (File Processing); Liang 10e §12 (Exception Handling and Text I/O). Section numbers are grounded from the published tables of contents; exact page numbers depend on the printing and are pending a faculty spot-check.

Show 3 more resources
  • Java SE 25 API: java.util.Scanner and java.io.File.
  • Practice: code.jdoner.me CSCD 210 file input exercises (coding practice and tracing).
  • Video (URL pending verification): BroCode, reading files with Scanner.