Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1033332 // zip2zip_collectFiles - collects files written

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4557L/26K).

static void zip2zip_collectFiles(File inZip, ZipOutputStream outZip, Set<S> filesWritten, IPred<S> predicate default name -> true) ctex {
  ZipFile zipFile = new ZipFile(inZip);
  try {
    Enumeration entries = zipFile.entries();
    while (entries.hasMoreElements()) {
      ZipEntry entry = (ZipEntry) entries.nextElement();
      if (entry.isDirectory()) continue;
      S name = entry.getName();
      
      if (!predicate.get(name)) continue;
      if (!filesWritten.add(name)) continue;
      
      outZip.putNextEntry(new ZipEntry(name));
      copyStreamAndCloseInput(zipFile.getInputStream(entry), outZip);
    }
  } finally {
    zipFile.close();
  }
}

Author comment

Began life as a copy of #1019060

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033332
Snippet name: zip2zip_collectFiles - collects files written
Eternal ID of this version: #1033332/4
Text MD5: 41fc7fa1d91a5d7992ceb4b63b99a9ee
Transpilation MD5: 0c10e1e463cfbd839d80badc6cc04f3e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-28 22:34:37
Source code size: 683 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 98 / 141
Version history: 3 change(s)
Referenced in: [show references]