Example Run

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

No. There are ways to deal with this problem covered in the chapter on exception handling.

Example Run

Here is an example run of the program:

C:/Temp/>java NamedFileInput
File Name:    myData.txt
The square of 1 is 1
The square of 2 is 4
The square of 3 is 9
The square of 10 is 100
The square of 11 is 121
The square of 12 is 144
The square of 13 is 169
The square of 23 is 529
The square of 45 is 2025
The square of 67 is 4489
C:/Temp/>

The user entered several spaces before the file name, but the trim() method took care of them. If this had not been done, the spaces would have been included as part of the file name and the file would not be found, resulting in a non-graceful termination of the probram.

QUESTION 11:

Is it ever useful to send output to a disk file?