Search in sources :

Example 21 with ZipFile

use of net.lingala.zip4j.core.ZipFile in project tdi-studio-se by Talend.

the class Unzip method doUnzipWithAes.

// zip4j compress&decryption impl
public void doUnzipWithAes() throws Exception {
    File file = new File(sourceZip);
    if (password == null || "".equals(password)) {
        // To make sure the System.out.println message
        Thread.sleep(1000);
        // come before
        throw new RuntimeException("Please enter the password and try again..");
    }
    ZipFile zipFile = new ZipFile(sourceZip);
    if (checkArchive) {
        if (!zipFile.isValidZipFile()) {
            throw new RuntimeException("The file " + sourceZip + " is corrupted, process terminated...");
        }
    }
    if (zipFile.isEncrypted()) {
        zipFile.setPassword(password);
    }
    List fileHeaderList = zipFile.getFileHeaders();
    if (fileHeaderList == null) {
        return;
    }
    for (int i = 0; i < fileHeaderList.size(); i++) {
        FileHeader fileHeader = (FileHeader) fileHeaderList.get(i);
        String filename = fileHeader.getFileName();
        if (verbose) {
            System.out.println("Source file  : " + filename);
        }
        if (!extractPath) {
            filename = filename.replaceAll("\\\\", "/");
            filename = filename.substring(filename.lastIndexOf('/') + 1);
        }
        zipFile.extractFile(fileHeader, targetDir, null, filename);
    }
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) List(java.util.List) ZipFile(net.lingala.zip4j.core.ZipFile) File(java.io.File) FileHeader(net.lingala.zip4j.model.FileHeader)

Example 22 with ZipFile

use of net.lingala.zip4j.core.ZipFile in project bamboobsc by billchen198318.

the class JReportUtils method selfTestDecompress4Upload.

public static String selfTestDecompress4Upload(String uploadOid) throws ServiceException, IOException, Exception {
    String extractDir = Constants.getWorkTmpDir() + "/" + JReportUtils.class.getSimpleName() + "/" + SimpleUtils.getUUIDStr() + "/";
    File realFile = UploadSupportUtils.getRealFile(uploadOid);
    try {
        ZipFile zipFile = new ZipFile(realFile);
        zipFile.extractAll(extractDir);
    } catch (Exception e) {
        throw e;
    } finally {
        realFile = null;
    }
    return extractDir;
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) ZipFile(net.lingala.zip4j.core.ZipFile) File(java.io.File) JRException(net.sf.jasperreports.engine.JRException) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Example 23 with ZipFile

use of net.lingala.zip4j.core.ZipFile in project bamboobsc by billchen198318.

the class BusinessProcessManagementUtils method decompressResource.

public static File[] decompressResource(File resourceZipFile) throws Exception {
    String extractDir = Constants.getWorkTmpDir() + "/" + BusinessProcessManagementUtils.class.getSimpleName() + "/" + SimpleUtils.getUUIDStr() + "/";
    ZipFile zipFile = new ZipFile(resourceZipFile);
    zipFile.extractAll(extractDir);
    File dir = new File(extractDir);
    return dir.listFiles();
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) ZipFile(net.lingala.zip4j.core.ZipFile) File(java.io.File)

Example 24 with ZipFile

use of net.lingala.zip4j.core.ZipFile in project sonarlint-core by SonarSource.

the class SonarlintInstaller method installZip.

private void installZip(Path zipFilePath, Path toDir) {
    try {
        ZipFile zipFile = new ZipFile(zipFilePath.toFile());
        zipFile.extractAll(toDir.toString());
    } catch (Exception e) {
        throw new IllegalStateException("Fail to unzip SonarLint Daemon to" + toDir, e);
    }
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile)

Example 25 with ZipFile

use of net.lingala.zip4j.core.ZipFile in project grakn by graknlabs.

the class DistributionContext method unzipDistribution.

private void unzipDistribution() throws ZipException {
    // Unzip the distribution
    ZipFile zipped = new ZipFile(ZIP_FULLPATH.toFile());
    zipped.extractAll(TARGET_DIRECTORY.toAbsolutePath().toString());
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile)

Aggregations

ZipFile (net.lingala.zip4j.core.ZipFile)38 File (java.io.File)20 ZipException (net.lingala.zip4j.exception.ZipException)16 ZipParameters (net.lingala.zip4j.model.ZipParameters)13 IOException (java.io.IOException)9 FileHeader (net.lingala.zip4j.model.FileHeader)8 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Nonnull (javax.annotation.Nonnull)4 WorldException (com.voxelgameslib.voxelgameslib.exception.WorldException)3 ByteArrayOutputStream (com.codeforces.commons.io.ByteArrayOutputStream)2 Map (com.voxelgameslib.voxelgameslib.map.Map)2 FileOutputStream (java.io.FileOutputStream)2 FileMeta (org.molgenis.data.file.model.FileMeta)2 CommandPermission (co.aikar.commands.annotation.CommandPermission)1 Subcommand (co.aikar.commands.annotation.Subcommand)1 Syntax (co.aikar.commands.annotation.Syntax)1 com.codeforces.commons.io (com.codeforces.commons.io)1 Math.max (com.codeforces.commons.math.Math.max)1 Patterns (com.codeforces.commons.text.Patterns)1