Search in sources :

Example 1 with ZipParameters

use of net.lingala.zip4j.model.ZipParameters in project ARChon-Packager by bpear96.

the class Step3 method archiveDir.

private void archiveDir(String path) {
    try {
        // Initiate ZipFile object with the path/name of the zip file.
        String zipname = g.getSelectedAppName();
        ZipFile zipFile = new ZipFile(Environment.getExternalStorageDirectory() + "/ChromeAPKS/" + zipname + ".zip");
        // Folder to add
        String folderToAdd = path;
        // Initiate Zip Parameters which define various properties such
        // as compression method, etc.
        ZipParameters parameters = new ZipParameters();
        // set compression method to store compression
        parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
        // Set the compression level
        parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
        // Add folder to the zip file
        zipFile.addFolder(folderToAdd, parameters);
        ArrayList filesToAdd = new ArrayList();
        filesToAdd.add(new File(path + "app_main.html"));
        filesToAdd.add(new File(path + "icon.png"));
        zipFile.addFiles(filesToAdd, parameters);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) ArrayList(java.util.ArrayList) ZipFile(net.lingala.zip4j.core.ZipFile) File(java.io.File) IOException(java.io.IOException) ZipParameters(net.lingala.zip4j.model.ZipParameters)

Example 2 with ZipParameters

use of net.lingala.zip4j.model.ZipParameters in project tdi-studio-se by Talend.

the class Zip method doZip2.

// zip4j impl
private void doZip2(final File source, final List<File> list) throws Exception {
    ZipFile zipFile = new ZipFile(targetZip);
    if ("UTF-8".equalsIgnoreCase(encoding)) {
        encoding = "UTF8";
    }
    zipFile.setFileNameCharset(encoding);
    ZipParameters params = new ZipParameters();
    params.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
    params.setCompressionLevel(compressLevel);
    if (isEncrypted && !"".equals(password)) {
        params.setEncryptFiles(true);
        params.setEncryptionMethod(encryptionMethod);
        if (Zip4jConstants.ENC_METHOD_AES == encryptionMethod) {
            params.setAesKeyStrength(aesKeyStrength);
        }
        params.setPassword(password);
    }
    params.setDefaultFolderPath(source.getAbsoluteFile().getPath());
    zipFile.addFiles((ArrayList) list, params);
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) ZipParameters(net.lingala.zip4j.model.ZipParameters)

Example 3 with ZipParameters

use of net.lingala.zip4j.model.ZipParameters in project apex-core by apache.

the class AppPackage method createAppPackageFile.

public static void createAppPackageFile(File fileToBeCreated, File directory) throws ZipException {
    ZipFile zipFile = new ZipFile(fileToBeCreated);
    ZipParameters params = new ZipParameters();
    params.setIncludeRootFolder(false);
    zipFile.addFolder(directory, params);
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) ZipParameters(net.lingala.zip4j.model.ZipParameters)

Example 4 with ZipParameters

use of net.lingala.zip4j.model.ZipParameters in project bamboobsc by billchen198318.

the class PdcaReportExcelCommand method createZipFile.

private String createZipFile(List<SysUploadVO> uploads) throws Exception {
    ZipFile zip = new ZipFile(Constants.getWorkTmpDir() + SimpleUtils.getUUIDStr() + ".zip");
    ZipParameters parameters = new ZipParameters();
    parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
    parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
    for (SysUploadVO reportUpload : uploads) {
        zip.addFile(UploadSupportUtils.getRealFile(reportUpload.getOid()), parameters);
    }
    return UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, zip.getFile(), "pdca-report.zip");
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) ZipParameters(net.lingala.zip4j.model.ZipParameters)

Example 5 with ZipParameters

use of net.lingala.zip4j.model.ZipParameters in project apex-core by apache.

the class StramTestSupport method createConfigPackageFile.

/**
   * Create an confPackage zip using the sample confPackage located in
   * src/test/resources/testConfPackage/testConfPackageSrc.
   *
   * @param file The file whose path will be used to create the confPackage zip
   * @return The File object that can be used in the ConfigPackage constructor.
   * @throws net.lingala.zip4j.exception.ZipException
   */
public static File createConfigPackageFile(File file) throws net.lingala.zip4j.exception.ZipException {
    ZipFile zipFile = new ZipFile(file);
    ZipParameters zipParameters = new ZipParameters();
    zipParameters.setIncludeRootFolder(false);
    zipFile.createZipFileFromFolder("src/test/resources/testConfigPackage/testConfigPackageSrc", zipParameters, false, Long.MAX_VALUE);
    return file;
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) ZipParameters(net.lingala.zip4j.model.ZipParameters)

Aggregations

ZipParameters (net.lingala.zip4j.model.ZipParameters)8 ZipFile (net.lingala.zip4j.core.ZipFile)6 BinaryContent (ddf.catalog.data.BinaryContent)2 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)2 IOException (java.io.IOException)2 ZipException (net.lingala.zip4j.exception.ZipException)2 SysUploadVO (com.netsteadfast.greenstep.vo.SysUploadVO)1 Result (ddf.catalog.data.Result)1 BinaryContentImpl (ddf.catalog.data.impl.BinaryContentImpl)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 Resource (ddf.catalog.resource.Resource)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1