public void close ( ) throws IOException { if ( t1 == null || t2 == null ) { return ; } try { if ( getOutput ( ) . length ( ) > 0 ) { Files . copy ( getOutput ( ) . toPath ( ) , output . toPath ( ) , StandardCopyOption . REPLACE_EXISTING ) ; } else if ( getInput ( ) . length ( ) > 0 ) { Files . copy ( getInput ( ) . toPath ( ) , output . toPath ( ) , StandardCopyOption . REPLACE_EXISTING ) ; } else { throw new IOException ( "Temporary files corrupted." ) ; } } finally { t1 . delete ( ) ; t2 . delete ( ) ; t1 = null ; t2 = null ; } }
Closes the temporary files and copies the result to the output file . Closing the TempFileHandler is a mandatory last step after which no other calls to the object should be made .