question: private Writer initWriter ( File file , Charset encoding , boolean append ) throws IOException { boolean fileExistedAlready = file . exists ( ) ; OutputStream stream = null ; Writer writer = null ; try { stream = new FileOutputStream ( file . getAbsolutePath ( ) , append ) ; writer = new OutputStreamWriter ( stream , Charsets . toCharset ( encoding ) ) ; } catch ( IOException ex ) { IOUtils . closeQuietly ( writer ) ; IOUtils . closeQuietly ( stream ) ; FileUtils . deleteQuietly ( lockFile ) ; if ( fileExistedAlready == false ) { FileUtils . deleteQuietly ( file ) ; } throw ex ; } catch ( RuntimeException ex ) { IOUtils . closeQuietly ( writer ) ; IOUtils . closeQuietly ( stream ) ; FileUtils . deleteQuietly ( lockFile ) ; if ( fileExistedAlready == false ) { FileUtils . deleteQuietly ( file ) ; } throw ex ; } return writer ; }
target:  Initialise the wrapped file writer. Ensure that a cleanup occurs if the writer creation fails.