public OutputStream getOutputStream ( ) throws IOException { acquireLock ( ) ; try { isClosed = false ; forWrite = true ; LOG . trace ( "Starts write '{}'" , file ) ; verifyAndRecover ( ) ; if ( Files . exists ( file ) ) { Files . move ( file , fileOld ) ; LOG . trace ( "Starting write, move '{}' to '{}'" , file , fileOld ) ; } OutputStream os = new ProxyOutputStream ( new FileOutputStream ( fileTmp . toFile ( ) ) ) { @ Override public void close ( ) throws IOException { if ( isClosed ) { return ; } try { super . close ( ) ; } finally { isClosed = true ; stream = null ; } LOG . trace ( "Finishes write '{}'" , file ) ; } } ; stream = os ; return os ; } catch ( Exception ex ) { release ( ) ; throw ex ; } }
Returns an output stream for the requested file .