public static File writeStringToTempFile ( String contents , String path , String encoding ) throws IOException { OutputStream writer = null ; File tmp = File . createTempFile ( path , ".tmp" ) ; if ( path . endsWith ( ".gz" ) ) { writer = new GZIPOutputStream ( new FileOutputStream ( tmp ) ) ; } else { writer = new BufferedOutputStream ( new FileOutputStream ( tmp ) ) ; } writer . write ( contents . getBytes ( encoding ) ) ; writer . close ( ) ; return tmp ; }
Writes a string to a temporary file