try {

} catch(...) {

} finally {
  if(writer != null) writer.close();
}