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

18
LINES

< > BotCompany Repo | #1025023 // zip2dir_withPredicate_overwriteIfDifferentSize

JavaX fragment (include)

static void zip2dir_withPredicate_overwriteIfDifferentSize(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());
    if (fileSize(outFile) == entry.getSize()) continue;
    
    System.out.println("Unzipping " + entry.getName() + " to " + outFile.getAbsolutePath());
    
    stream2file(zipFile.getInputStream(entry), outFile);
  }
}

Author comment

Began life as a copy of #1025022

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: #1025023
Snippet name: zip2dir_withPredicate_overwriteIfDifferentSize
Eternal ID of this version: #1025023/1
Text MD5: 40060a27800ead4cd3e6582df2363f99
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:20:12
Source code size: 761 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 172 / 211
Referenced in: [show references]