当前位置: 首页>>代码示例>>Java>>正文


Java ZipParameters.setCompressionLevel方法代码示例

本文整理汇总了Java中net.lingala.zip4j.model.ZipParameters.setCompressionLevel方法的典型用法代码示例。如果您正苦于以下问题:Java ZipParameters.setCompressionLevel方法的具体用法?Java ZipParameters.setCompressionLevel怎么用?Java ZipParameters.setCompressionLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.lingala.zip4j.model.ZipParameters的用法示例。


在下文中一共展示了ZipParameters.setCompressionLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compress

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
public void compress(Transformation transformation) {
    File inputFile = transformation.getTransformedApplicationLocation().getAbsoluteFile();
    File compressedFile = new File(transformation.getTransformedApplicationLocation().getAbsolutePath() + ".zip");

    logger.info("Compressing transformed application");

    try {
        ZipFile zipFile = new ZipFile(compressedFile);
        ZipParameters parameters = new ZipParameters();

        parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
        parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);

        zipFile.addFolder(inputFile, parameters);
        FileUtils.deleteDirectory(transformation.getTransformedApplicationLocation());

        logger.info("Transformed application has been compressed to {}", compressedFile.getAbsoluteFile());
    } catch (Exception e) {
        logger.error("Error when compressing transformed application", e);
    }
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:22,代码来源:CompressionHandler.java

示例2: zip

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
public static void zip(String targetPath, String destinationFilePath, String password) {
    try {
        ZipParameters parameters = new ZipParameters();
        parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
        parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);

        if (password.length() > 0) {
            parameters.setEncryptFiles(true);
            parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_AES);
            parameters.setAesKeyStrength(Zip4jConstants.AES_STRENGTH_256);
            parameters.setPassword(password);
        }

        ZipFile zipFile = new ZipFile(destinationFilePath);

        File targetFile = new File(targetPath);
        if (targetFile.isFile()) {
            zipFile.addFile(targetFile, parameters);
        } else if (targetFile.isDirectory()) {
            zipFile.addFolder(targetFile, parameters);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:ghost1372,项目名称:Mzip-Android,代码行数:27,代码来源:ZipArchive.java

示例3: compress

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
/**
 * Compress.
 *
 * @param fileName
 *            the file name
 * @param compressedFileName
 *            the compressed file name
 * @param password
 *            the password
 */
public static void compress(String fileName, String compressedFileName, String password) {
	try {
		ZipParameters zipParameters = new ZipParameters();
		zipParameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
		zipParameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_ULTRA);
		if (password != null) {
			zipParameters.setEncryptFiles(true);
			zipParameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_AES);
			zipParameters.setAesKeyStrength(Zip4jConstants.AES_STRENGTH_256);
			zipParameters.setPassword(password);
		}
		String destinationZipFilePath = compressedFileName;
		ZipFile zipFile = new ZipFile(destinationZipFilePath);
		zipFile.addFile(new File(fileName), zipParameters);
	} catch (ZipException e) {
		JKExceptionUtil.handle(e);
	}
}
 
开发者ID:kiswanij,项目名称:jk-util,代码行数:29,代码来源:JKCompressionUtil.java

示例4: AddFolder

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
public AddFolder() {
	
	try {
		// Initiate ZipFile object with the path/name of the zip file.
		ZipFile zipFile = new ZipFile("c:\\ZipTest\\AddFolder.zip");
		
		// Folder to add
		String folderToAdd = "c:\\FolderToAdd";
		
		// 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);
		
	} catch (ZipException e) {
		e.printStackTrace();
	}
}
 
开发者ID:joielechong,项目名称:Zip4jAndroid,代码行数:27,代码来源:AddFolder.java

示例5: compile

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
public static void compile(String pkgroot){
	
	try {
		File parent = new File(pkgroot).getParentFile();
		String name = new File(pkgroot).getName() + ".atomx";
		ZipFile zipFile = new ZipFile(new File(parent, name));
		ZipParameters parameters = new ZipParameters();
		parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
		parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
		parameters.setIncludeRootFolder(false);
		zipFile.addFolder(pkgroot, parameters);
		
	} catch (ZipException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
}
 
开发者ID:arjay07,项目名称:AtomScript,代码行数:19,代码来源:ASPackage.java

示例6: zip

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
/**
 * Archives the list of files to a zip archive
 *
 * @param zipFileName
 * @param fileList
 * @param desaElement
 * @throws MetsExportException
 */
private void zip(String zipFileName, ArrayList<File> fileList, IDesaElement desaElement) throws MetsExportException {
    try {
        File file = new File(zipFileName);
        if (file.exists()) {
            file.delete();
            file = null;
            LOG.log(Level.FINE, "File:" + zipFileName + " exists, so it was deleted");
        }
        ZipFile zipFile = new ZipFile(zipFileName);
        ZipParameters zip4jZipParameters = new ZipParameters();
        zip4jZipParameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
        zip4jZipParameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
        zipFile.addFiles(fileList, zip4jZipParameters);
        LOG.log(Level.FINE, "Zip archive created:" + zipFileName + " for " + desaElement.getElementType());
    } catch (ZipException e) {
        throw new MetsExportException(desaElement.getOriginalPid(), "Unable to create a zip file:" + zipFileName, false, e);
    }

}
 
开发者ID:proarc,项目名称:proarc,代码行数:28,代码来源:DesaElementVisitor.java

示例7: initZipParameters

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
/**
 * 
 * @return ZipParameters
 */
private ZipParameters initZipParameters() {
			
	// Initiate Zip Parameters which define various properties such
	// as compression method, etc. More parameters are explained in other
	// examples
	ZipParameters zpParameters = new ZipParameters();
	
	// set compression method to deflate compression
	zpParameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); 
	
	/* 
	 Set the compression level. This value has to be in between 0 to 9
	 Several predefined compression levels are available
	 DEFLATE_LEVEL_FASTEST - Lowest compression level but higher speed of compression
	 DEFLATE_LEVEL_FAST - Low compression level but higher speed of compression
	 DEFLATE_LEVEL_NORMAL - Optimal balance between compression level/speed
	 DEFLATE_LEVEL_MAXIMUM - High compression level with a compromise of speed
	 DEFLATE_LEVEL_ULTRA - Highest compression level but low speed
	*/
	zpParameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); 
	
	return zpParameters;
}
 
开发者ID:Comcast,项目名称:Oscar,代码行数:28,代码来源:ConfigurationFile.java

示例8: ArchiverWorker

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
public ArchiverWorker(GameSet romSet, ArchiveMergerPlugin plugin, Consumer<Boolean> callback)
{
  super(romSet, plugin, r -> r.getStatus().isComplete(), callback);
  
  try
  {
    zfile = new ZipFile(Main.setManager.settings(romSet).romsPath.resolve("romset.zip").toFile());
    zparams = new ZipParameters();
    aparams = new ZipParameters();
  
    zparams.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
    zparams.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
    
    aparams.setCompressionLevel(Zip4jConstants.COMP_DEFLATE);
    aparams.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
    aparams.setSourceExternalStream(true);
  }
  catch (Exception e)
  {
    e.printStackTrace();
  }
}
 
开发者ID:Jakz,项目名称:rom-manager,代码行数:23,代码来源:ArchiveMergerPlugin.java

示例9: withData

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
private void withData(AppsModel model, ApplicationInfo packageInfo, File file, FileUtil fileUtil, int count) throws Exception {
    File dataFolder = new File(packageInfo.dataDir);
    File dataFile = new File(fileUtil.getBaseFolderName() + model.getPackageName());
    boolean z = RootManager.getInstance().copyFile(dataFolder.getPath(), fileUtil.getBaseFolderName());
    ZipParameters parameters = new ZipParameters();
    parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
    parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_FASTEST);
    if (z) {
        if (dataFile.exists()) {
            zipData.addFolder(dataFile, parameters);
            FileUtils.deleteDirectory(dataFile);
        }
    }
    ProgressModel progressModel = new ProgressModel();
    progressModel.setProgress(count);
    progressModel.setFileName(model.getAppName());
    publishProgress(progressModel);
}
 
开发者ID:k0shk0sh,项目名称:KAM,代码行数:19,代码来源:BackupAppsTasker.java

示例10: createZipFile

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
private File createZipFile(String[] outputFilenames) throws IOException, ZipException {
    // We want a temporary filename but the file must not yet exist. So create a temporary file then delete it.
    File file = File.createTempFile("outputs", ".zip");
    deleteZipFile(file);

    ZipFile zipFile = new ZipFile(file);
    ZipParameters zipParameters = new ZipParameters();
    zipParameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);

    // Add files to zip file
    ArrayList<File> filesToAdd = new ArrayList<>();
    for (String outputFilename : outputFilenames) {
        File fileToAdd = getFileInWorkingDirectory(outputFilename);
        if (fileToAdd.exists()) {
            filesToAdd.add(fileToAdd);
        } else {
            throw new IllegalArgumentException("File does not exist: " + fileToAdd.getAbsolutePath());
        }
    }

    zipFile.createZipFile(filesToAdd, zipParameters);

    return file;
}
 
开发者ID:SEEG-Oxford,项目名称:ABRAID-MP,代码行数:25,代码来源:ModelStatusReporterImpl.java

示例11: compact

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
@Override
public String compact(String in, int compressionLevel) throws IOException {

    File out = new File(in + ".zip4j");
    try {

        ZipFile zipFile = new ZipFile(out.getAbsolutePath());
        ZipParameters parametes = new ZipParameters();
        parametes.setCompressionLevel(compressionLevel);
        zipFile.addFile(new File(in), parametes);

    } catch (ZipException e) {
        throw new IOException(e);
    }
    return out.getAbsolutePath();
}
 
开发者ID:bionimbuz,项目名称:Bionimbuz,代码行数:17,代码来源:Zip4JCompactor.java

示例12: example1

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
/**
 * 示例1 创建压缩包添加文件到压缩包中(未设置加密)
 */
@Test
public void example1(){
	try {
           
           ZipFile zipFile = new ZipFile("src/main/resources/AddFilesDeflateComp.zip");
            
           ArrayList<File> filesToAdd = new ArrayList<File>();
           filesToAdd.add(new File("src/main/resources/sample.txt"));
           filesToAdd.add(new File("src/main/resources/zip4j.txt"));
           filesToAdd.add(new File("src/main/resources/zip4j-1.3.2.jar"));
            
           ZipParameters parameters = new ZipParameters();
           parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); // set compression method to deflate compression
           parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); 
           zipFile.addFiles(filesToAdd, parameters);
           
           CompressUtil.printZipInfo("src/main/resources/AddFilesDeflateComp.zip");
           
           
       } catch (ZipException e) {
           e.printStackTrace();
       }
}
 
开发者ID:v5developer,项目名称:maven-framework-project,代码行数:27,代码来源:Zip4j.java

示例13: example2

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
/**
 * 示例2 创建压缩包添加文件到指定目录中进行压缩
 */
@Test
public void example2(){
	try {
           ZipFile zipFile = new ZipFile("src/main/resources/AddFilesDeflateComp.zip");
           ArrayList<File> filesToAdd = new ArrayList<File>();
           filesToAdd.add(new File("src/main/resources/sample.txt"));
           filesToAdd.add(new File("src/main/resources/zip4j.txt"));
           filesToAdd.add(new File("src/main/resources/zip4j-1.3.2.jar"));
            
           ZipParameters parameters = new ZipParameters();
           parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
            
           parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
           parameters.setRootFolderInZip("target/");

           zipFile.addFiles(filesToAdd, parameters);
       } catch (ZipException e) {
           e.printStackTrace();
       } 
}
 
开发者ID:v5developer,项目名称:maven-framework-project,代码行数:24,代码来源:Zip4j.java

示例14: example3

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
/**
 * 示例3 添加文件夹到压缩包中
 */
@Test
public void example3(){
	try {
           
           ZipFile zipFile = new ZipFile("src/main/resources/AddFolder.zip");
           String folderToAdd = "src/main/resources";
        
           ZipParameters parameters = new ZipParameters();
            
           parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
           parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
           zipFile.addFolder(folderToAdd, parameters);
            
       } catch (ZipException e) {
           e.printStackTrace();
       }
}
 
开发者ID:v5developer,项目名称:maven-framework-project,代码行数:21,代码来源:Zip4j.java

示例15: example5

import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
/**
 * 示例5 创建分卷压缩包
 */
@Test
public void example5(){
	try {
         
           ZipFile zipFile = new ZipFile("src/main/resources/CreateSplitZipFile.zip");

           ArrayList<File> filesToAdd = new ArrayList<File>();
           filesToAdd.add(new File("src/main/resources/sample.txt"));
           filesToAdd.add(new File("src/main/resources/zip4j.txt"));
           filesToAdd.add(new File("src/main/resources/zip4j-1.3.2.jar"));
            
           ZipParameters parameters = new ZipParameters();
           parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
            
           parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
            
           zipFile.createZipFile(filesToAdd, parameters, true, 65536);
       } catch (ZipException e) {
           e.printStackTrace();
       }
}
 
开发者ID:v5developer,项目名称:maven-framework-project,代码行数:25,代码来源:Zip4j.java


注:本文中的net.lingala.zip4j.model.ZipParameters.setCompressionLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。