...
This compliant solution handles a FileNotFoundException
by requesting that the user specify another file name:
Code Block | ||
---|---|---|
| ||
volatile boolean validFlag = false;
do {
try {
// If requested file does not exist, throws FileNotFoundException
// If requested file exists, sets validFlag to true
validFlag = true;
} catch (FileNotFoundException e) {
// Ask the user for a different file name
}
} while (validFlag != true);
// Use the file
|
...