Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused IOUtils.unzip #29

Merged
merged 3 commits into from Apr 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Next
remove unused IOUtils.unzip
  • Loading branch information
robberphex committed Apr 7, 2022
commit 359603b63fc6c59d8b57e061c171954bab3433bf
Expand Up @@ -103,60 +103,4 @@ public static IOException close(URLClassLoader urlClassLoader) {
return null;
}

public static void unzip(String zipFile, String extractFolder) throws IOException {
File file = new File(zipFile);
ZipFile zip = null;
try {
int BUFFER = 1024 * 8;

zip = new ZipFile(file);
String newPath = extractFolder;

new File(newPath).mkdir();
Enumeration<? extends ZipEntry> zipFileEntries = zip.entries();

// Process each entry
while (zipFileEntries.hasMoreElements()) {
// grab a zip file entry
ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();
String currentEntry = entry.getName();

File destFile = new File(newPath, currentEntry);
// destFile = new File(newPath, destFile.getName());
File destinationParent = destFile.getParentFile();

// create the parent directory structure if needed
destinationParent.mkdirs();

if (!entry.isDirectory()) {
BufferedInputStream is = null;
BufferedOutputStream dest = null;
try {
is = new BufferedInputStream(zip.getInputStream(entry));
int currentByte;
// establish buffer for writing file
byte data[] = new byte[BUFFER];

// write the current file to disk
FileOutputStream fos = new FileOutputStream(destFile);
dest = new BufferedOutputStream(fos, BUFFER);

// read and write until last byte is encountered
while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
dest.write(data, 0, currentByte);
}
dest.flush();
} finally {
close(dest);
close(is);
}

}

}
} finally {
close(zip);
}

}
}