public static void writeToFile ( byte [ ] catalogBytes , File file ) throws IOException { JarOutputStream jarOut = new JarOutputStream ( new FileOutputStream ( file ) ) ; JarInputStream jarIn = new JarInputStream ( new ByteArrayInputStream ( catalogBytes ) ) ; JarEntry catEntry = null ; JarInputStreamReader reader = new JarInputStreamReader ( ) ; while ( ( catEntry = jarIn . getNextJarEntry ( ) ) != null ) { byte [ ] value = reader . readEntryFromStream ( jarIn ) ; String key = catEntry . getName ( ) ; assert ( value != null ) ; JarEntry entry = new JarEntry ( key ) ; entry . setSize ( value . length ) ; entry . setTime ( System . currentTimeMillis ( ) ) ; jarOut . putNextEntry ( entry ) ; jarOut . write ( value ) ; jarOut . flush ( ) ; jarOut . closeEntry ( ) ; } jarOut . finish ( ) ; jarIn . close ( ) ; }
directly transformed and written to the specified file