public static Resource temporaryDirectory ( ) { File tempDir = new File ( SystemInfo . JAVA_IO_TMPDIR ) ; String baseName = System . currentTimeMillis ( ) + "-" ; for ( int i = 0 ; i < 1_000_000 ; i ++ ) { File tmp = new File ( tempDir , baseName + i ) ; if ( tmp . mkdir ( ) ) { return new FileResource ( tmp ) ; } } throw new RuntimeException ( "Unable to create temp directory" ) ; }
Creates a new Resource that points to a temporary directory .