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

16
LINES

< > BotCompany Repo | #1025022 // zip2dir_withPredicate

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

Libraryless. Click here for Pure Java version (2160L/14K).

static void zip2dir_withPredicate(File inZip, File outDir, IF1<S, Bool> pred) ctex {
  temp ZipFile zipFile = new ZipFile(inZip);
  Enumeration entries = zipFile.entries();
  while (entries.hasMoreElements()) {
    ZipEntry entry = (ZipEntry) entries.nextElement(); 
    
    if (entry.isDirectory()) continue; // We care about files only, really. Directories are made on the fly anyway.
    
    if (!pred.get(entry.getName())) continue;
    
    File outFile = new File(outDir, entry.getName());
    System.out.println("Unzipping " + entry.getName() + " to " + outFile.getAbsolutePath());
    
    stream2file(zipFile.getInputStream(entry), outFile);
  }
}

Author comment

Began life as a copy of #1001335

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025022
Snippet name: zip2dir_withPredicate
Eternal ID of this version: #1025022/3
Text MD5: 56378204de0a0085e55910800bc722e7
Transpilation MD5: cae8824ea9c396b2247319da858d2de4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-01 17:00:26
Source code size: 673 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 160 / 231
Version history: 2 change(s)
Referenced in: [show references]