public static List < String > listZipContents ( File zipFile , String path ) throws IOException { List < String > names = new ArrayList <> ( ) ; if ( zipFile . isFile ( ) ) { ZipFile zip = null ; try { zip = new ZipFile ( zipFile ) ; Enumeration < ? extends ZipEntry > entries = zip . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry entry = entries . nextElement ( ) ; String name = entry . getName ( ) ; if ( ! entry . isDirectory ( ) && name . startsWith ( path ) ) { names . add ( name ) ; } } } finally { close ( zip ) ; } } return names ; }
Lists the contents of a zip file . Only looks in the supplied path within the zip file .