private void writeResult ( Object result ) throws IOException { File outputFile = new File ( outputFileLocation ) ; File tempfile = FileSupport . createFile ( tempOutputFileLocation ) ; FileOutputStream fos = null ; try { fos = new FileOutputStream ( tempfile ) ; PrintStream ps = new PrintStream ( new FileOutputStream ( tempfile ) ) ; if ( result != null ) { if ( result instanceof Throwable ) { ( ( Throwable ) result ) . printStackTrace ( ps ) ; } ps . println ( result . toString ( ) ) ; } ps . close ( ) ; } finally { fos . close ( ) ; } if ( outputFile . exists ( ) ) { boolean success = outputFile . delete ( ) ; } boolean success = tempfile . renameTo ( new File ( outputFileLocation ) ) ; }
Writes result to the output file .