private static void copyEntries ( File zip , final ZipOutputStream out , final Set < String > ignoredEntries ) { final Set < String > names = new HashSet < String > ( ) ; final Set < String > dirNames = filterDirEntries ( zip , ignoredEntries ) ; iterate ( zip , new ZipEntryCallback ( ) { public void process ( InputStream in , ZipEntry zipEntry ) throws IOException { String entryName = zipEntry . getName ( ) ; if ( ignoredEntries . contains ( entryName ) ) { return ; } for ( String dirName : dirNames ) { if ( entryName . startsWith ( dirName ) ) { return ; } } if ( names . add ( entryName ) ) { ZipEntryUtil . copyEntry ( zipEntry , in , out ) ; } else if ( log . isDebugEnabled ( ) ) { log . debug ( "Duplicate entry: {}" , entryName ) ; } } } ) ; }
Copies all entries from one ZIP file to another ignoring entries with path in ignoredEntries