public static void findZip ( String zipName , InputStream zipInput , FileFilter searchFilter , List < String > results ) throws IOException { ZipInputStream zin = new ZipInputStream ( zipInput ) ; while ( true ) { final ZipEntry en ; try { en = zin . getNextEntry ( ) ; } catch ( IOException | IllegalArgumentException e ) { throw new IOException ( "While handling file " + zipName , e ) ; } if ( en == null ) { break ; } if ( searchFilter . accept ( new File ( en . getName ( ) ) ) ) { results . add ( zipName + ZIP_DELIMITER + en ) ; } if ( ZipUtils . isZip ( en . getName ( ) ) ) { findZip ( zipName + ZIP_DELIMITER + en , zin , searchFilter , results ) ; } } }
Looks in the ZIP file available via zipInput for files matching the provided file - filter recursing into sub - ZIP files .