public static File createTempDirectory ( String prefix ) { File temp = null ; try { temp = File . createTempFile ( prefix != null ? prefix : "temp" , Long . toString ( System . nanoTime ( ) ) ) ; if ( ! ( temp . delete ( ) ) ) { throw new IOException ( "Could not delete temp file: " + temp . getAbsolutePath ( ) ) ; } if ( ! ( temp . mkdir ( ) ) ) { throw new IOException ( "Could not create temp directory: " + temp . getAbsolutePath ( ) ) ; } } catch ( IOException e ) { throw new DukeException ( "Unable to create temporary directory with prefix " + prefix , e ) ; } return temp ; }
Creates a temporary folder using the given prefix to generate its name .