Question: Run the FileClient with the debugger (with a breakpoint on the line with while). You'll need to create a file called input.txt in the src

Run the FileClient with the debugger (with a breakpoint on the line with while). You'll need to create a file called input.txt in the src folder (which the program will open) and add some (any) contents to it.

Expand the inputFileScanner variable in the debugger window to check out its stored data. How much of it can you make sense of?

Watch the values of keep looping, next word, and inputFileScanner's buf field in the debugger as you step through the loop multiple times.

In your documentation, address the following:

  • What do you think the Scanner's hasNext method does?

  • Theorize about what the while statement does.

Try to create a different while statement that does something else.

Use this code as a reference

import java.io.File; import java.util.Scanner; class FileClient { public static void main(String[] args) throws java.io.FileNotFoundException { File inputFile = new File("src/input.txt"); Scanner inputFileScanner = new Scanner(inputFile); while ( inputFileScanner.hasNext() ) { System.out.println(inputFileScanner.next()); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!