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

21
LINES

< > BotCompany Repo | #1024957 // zip2zip_withPredicate

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

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

static int zip2zip_withPredicate(File inZip, ZipOutputStream outZip, IF1<S, Bool> predicate) ctex {
  temp ZipFile zipFile = new ZipFile(inZip);
  Enumeration entries = zipFile.entries();
  int n = 0;
  while (entries.hasMoreElements()) {
    ZipEntry entry = (ZipEntry) entries.nextElement(); 
    continue unless predicate.get(entry.getName());
    ++n;
    outZip.putNextEntry(new ZipEntry(entry.getName()));
    
    InputStream fin = zipFile.getInputStream(entry);
    copyStream(fin, outZip);
    fin.close();
  }
  ret n;
}

static int zip2zip_withPredicate(File inZip, File outZip, IF1<S, Bool> predicate) {
  temp ZipOutputStream outStream = zipOutputStream(outZip);
  ret zip2zip_withPredicate(inZip, outStream, predicate);
}

Author comment

Began life as a copy of #1001173

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: #1024957
Snippet name: zip2zip_withPredicate
Eternal ID of this version: #1024957/4
Text MD5: 1c3ebc0f8ef6c7de65c2e4ad3078f51d
Transpilation MD5: b7fa1e1b3842f226fe5ec65325a24bb7
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-20 16:52:42
Source code size: 755 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 242 / 357
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)