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)

1  
static void zip2dir_withPredicate_overwriteIfDifferentSize(File inZip, File outDir, IF1<S, Bool> pred) ctex {
2  
  temp ZipFile zipFile = new ZipFile(inZip);
3  
  Enumeration entries = zipFile.entries();
4  
  while (entries.hasMoreElements()) {
5  
    ZipEntry entry = (ZipEntry) entries.nextElement(); 
6  
    
7  
    if (entry.isDirectory()) continue; // We care about files only, really. Directories are made on the fly anyway.
8  
    
9  
    if (!pred.get(entry.getName())) continue;
10  
    
11  
    File outFile = new File(outDir, entry.getName());
12  
    if (fileSize(outFile) == entry.getSize()) continue;
13  
    
14  
    System.out.println("Unzipping " + entry.getName() + " to " + outFile.getAbsolutePath());
15  
    
16  
    stream2file(zipFile.getInputStream(entry), outFile);
17  
  }
18  
}

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: 251 / 294
Referenced in: [show references]