Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void unzip() throws IOException {
- ArrayList<String> listOfArchives = getListOfFiles();
- for (String s : listOfArchives) {
- String filename = path + "/" + s;
- File file = new File(filename);
- if (!file.exists() || !file.canRead()) {
- System.out.println("File cannot be read");
- return;
- }
- ZipFile zip = new ZipFile(filename);
- try {
- Enumeration entries = zip.entries();
- while (entries.hasMoreElements()) {
- ZipEntry entry = (ZipEntry) entries.nextElement();
- if (!entry.isDirectory() && entry.getName().matches(regExpression)) {
- try (BufferedOutputStream bf = new BufferedOutputStream(new FileOutputStream(new File(file.getParent(), entry.getName())))) {
- write(zip.getInputStream(entry), bf);
- }
- }
- }
- zip.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement