Hàm Java giải nén tập tin Zip có hoặc không có password. | Java function decompress zip have password(be or not) using Zip4J.

Để sử dụng hàm Java này trước tiên bạn vào trang web của Zip4J để download thư việc JAR của nó về add vào project để sử dụng.


Java Function Decompress Zip File.
    public static void decompress(String zipFile, String dest, String password) {
        ZipFile zFile;
        try {
            zFile = new ZipFile(zipFile);

            if (!zFile.isValidZipFile()) {
                throw new ZipException("this is an broken zip file.");
            }
            File destDir = new File(dest);
            if (destDir.isDirectory() && !destDir.exists()) {
                destDir.mkdir();
            }
            if (zFile.isEncrypted()) {
                zFile.setPassword(password);
            }
            zFile.extractAll(dest);

        } catch (ZipException ex) {
            JOptionPane.showMessageDialog(null,ex.getMessage(),"Error warning",JOptionPane.ERROR_MESSAGE);
            Logger.getLogger(Citi_Support_Tools.class.getName()).log(Level.SEVERE, null, ex);
        }


    }



Related | Bài viết liên quan:







No comments:

Post a Comment