Read a text file line by line and print it back with line numbers | Workbook p.15-16
Create a Java app called bedtime-stories. In the provided DataFiles.zip you'll find three story files: goldilocks.txt, hansel_and_gretel.txt, and mary_had_a_little_lamb.txt. Place them in your project folder.
Ask the user which filename to read. Open the file with a BufferedReader, walk through it line by line, and print each line to the console — but add a line number before every line so the output looks like a numbered list.
Wrap the file work in a try/catch so a missing file gives a clean error message instead of a crash.
Workbook 3a, p.15-16 — Exercise: Bedtime Stories