public static Path createTempFolder ( String prefix ) throws IOException { Path parent = Paths . get ( System . getProperty ( "java.io.tmpdir" ) ) ; if ( ! Files . isDirectory ( parent ) ) { throw new IOException ( "java.io.tmpdir points to a non-existing folder: " + parent ) ; } Path ret = null ; int i = 0 ; do { ret = parent . resolve ( Objects . requireNonNull ( prefix ) + Long . toHexString ( System . currentTimeMillis ( ) ) + "-" + Integer . toHexString ( RND . nextInt ( ) ) ) ; i ++ ; if ( i >= 100 ) { throw new IOException ( "Failed to create temporary folder." ) ; } } while ( ! ret . toFile ( ) . mkdirs ( ) ) ; return ret ; }
Creates a temporary folder .