English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

1 answers

The finally clause is used in conjunction with a try catch statement. A finally statement will be executed no matter what goes wrong or even if all goes right in the try block.

try {
//read file1
//write to file2
//read non existing file will through an FileNotFoundException
}
catch(FileNotFoundException e){
//log or display errror
}
finally {
//close file 1 input stream
//close file 2 output stream
}

Basically, you perform commands that you must perform even in case of a failure in the finally.

2006-11-02 15:19:46 · answer #1 · answered by Wildjoe182 5 · 1 0

fedest.com, questions and answers