How to close file in IOException

Due to IOException cause file still open, the only way to unlock file is shutdown server,
I try to close file in IOException segment but get error,
We are pleasure for your help. Here is the part of code.

try {
RandomAccessFile in;
BufferedWriter out;

}
catch (IOException e) {
} finally {
try {
in.close();
out.close();
} catch (IOException e) {}
}

“I try to close file in IOException segment but get error”

What’s the error?

As you have seen in the above code the objects were declared in the try block and they are not recognizable in finally block.Hence the error.