public void close ( ) throws IOException { if ( t1 == null || t2 == null ) { return ; } try { if ( ! isEmpty ( getOutput ( ) ) ) { Optional < ? extends IOException > ex = output . apply ( getOutput ( ) ) ; if ( ex . isPresent ( ) ) { throw ex . get ( ) ; } } else if ( ! isEmpty ( getInput ( ) ) ) { Optional < ? extends IOException > ex = output . apply ( getInput ( ) ) ; if ( ex . isPresent ( ) ) { throw ex . get ( ) ; } } else { throw new IOException ( "Corrupted state." ) ; } } finally { PathTools . deleteRecursive ( t1 ) ; PathTools . deleteRecursive ( t2 ) ; t1 = null ; t2 = null ; } }
Process the result with the output function and then closes the temporary folders . Closing the TempFolderHandler is a mandatory last step after which no other calls to the object should be made .