public static File getCopy ( String name , InputStream input ) { Check . notNull ( name ) ; Check . notNull ( input ) ; final String prefix ; final String suffix ; final int minimumPrefix = 3 ; final int i = name . lastIndexOf ( Constant . DOT ) ; if ( i > minimumPrefix ) { prefix = name . substring ( 0 , i ) ; suffix = name . substring ( i ) ; } else { if ( name . length ( ) > minimumPrefix ) { prefix = name ; } else { prefix = PREFIX_TEMP ; } suffix = null ; } try { final File temp = File . createTempFile ( prefix , suffix ) ; try ( OutputStream output = new BufferedOutputStream ( new FileOutputStream ( temp ) ) ) { copy ( input , output ) ; } return temp ; } catch ( final IOException exception ) { throw new LionEngineException ( exception , ERROR_TEMP_FILE + name ) ; } }
Get of full copy of the input stream stored in a temporary file .