Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void lookupSomethingInZip(InputStream is) throws IOException {
- ZipInputStream zipInputStream = new ZipInputStream(is);
- String entryName = "";
- ZipEntry entry = zipInputStream.getNextEntry();
- while (entry!=null) {
- entryName = entry.getName();
- if (entryName.endsWith("zip")) {
- //recur if the entry is a zip file
- lookupSomethingInZip(zipInputStream);
- }
- if (entryName.endsWith("txt")) {
- String str =
- new BufferedReader(new InputStreamReader(zipInputStream))
- .lines().collect(Collectors.joining("\n"));
- System.out.println(str);
- // if we need only first file
- break;
- }
- //do other operation with the entries..
- entry = zipInputStream.getNextEntry();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment