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

22
LINES

< > BotCompany Repo | #1001335 // zip2dir

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

Libraryless. Click here for Pure Java version (3211L/18K).

1  
static void zip2dir(File inZip, File/S outDir) {
2  
  zip2dir(inZip, outDir, "");
3  
}
4  
5  
static void zip2dir(File inZip, File/S outDir, S prefix) ctex {
6  
  if (prefix.length() != 0 && !prefix.endsWith("/")) prefix += "/";
7  
  
8  
  temp ZipFile zipFile = new ZipFile(inZip);
9  
  Enumeration entries = zipFile.entries();
10  
  while (entries.hasMoreElements()) {
11  
    ZipEntry entry = (ZipEntry) entries.nextElement(); 
12  
    
13  
    if (entry.isDirectory()) continue; // We care about files only, really. Directories are made on the fly anyway.
14  
    
15  
    if (!entry.getName().startsWith(prefix)) continue;
16  
    
17  
    File outFile = new File(outDir, entry.getName());
18  
    print("Unzipping " + entry.getName() + " to " + outFile.getAbsolutePath());
19  
    
20  
    stream2file(zipFile.getInputStream(entry), outFile);
21  
  }
22  
}

Author comment

Began life as a copy of #1001173

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001335
Snippet name: zip2dir
Eternal ID of this version: #1001335/4
Text MD5: 62d4b7420a26c4691a6bd719a35c6001
Transpilation MD5: b3bb3bc38346875cc1b14fd808def64f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-29 23:50:40
Source code size: 809 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 801 / 1054
Version history: 3 change(s)
Referenced in: [show references]