go to previous page   go to home page   go to next page

Answer:

Just one.


Input File for this Program

The example program reads just one line of text, no matter how many lines are in the file. Of course, the program could be written to read more than one line of data.

Here is an example input file, named input.txt.

This is line one of the file.
This is line two of the file.
The last line of the file.

Here is what the above program does when input.txt is redirected to it as input:

C:\temp>java Echo < input.txt

Enter your input:
You typed: This is line one of the file.

C:\temp>

QUESTION 4:

What will nextLine() return if a line of the text file contains only the newline character? This would happen if the user just hit "enter" in response to the prompt.

line = scan.nextLine();