Aa

Text size

?

Map / ArrayList & Data / 5

👣 Trace

Reading a file line by line

The program reads pets.txt (shown above). Step through and watch the Scanner's line move down the file.

  • File
  • Scanner
  • hasNextLine()
  • nextLine()
📄 pets.txt — a file the program reads
cat
dog
hamster