本文整理汇总了Java中net.lingala.zip4j.model.ZipParameters.getCompressionLevel方法的典型用法代码示例。如果您正苦于以下问题:Java ZipParameters.getCompressionLevel方法的具体用法?Java ZipParameters.getCompressionLevel怎么用?Java ZipParameters.getCompressionLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.lingala.zip4j.model.ZipParameters
的用法示例。
在下文中一共展示了ZipParameters.getCompressionLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkParameters
import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
private void checkParameters(ZipParameters parameters) throws ZipException {
if (parameters == null) {
throw new ZipException("cannot validate zip parameters");
}
if ((parameters.getCompressionMethod() != Zip4jConstants.COMP_STORE) &&
parameters.getCompressionMethod() != Zip4jConstants.COMP_DEFLATE) {
throw new ZipException("unsupported compression type");
}
if (parameters.getCompressionMethod() == Zip4jConstants.COMP_DEFLATE) {
if (parameters.getCompressionLevel() < 0 && parameters.getCompressionLevel() > 9) {
throw new ZipException("invalid compression level. compression level dor deflate should be in the range of 0-9");
}
}
if (parameters.isEncryptFiles()) {
if (parameters.getEncryptionMethod() != Zip4jConstants.ENC_METHOD_STANDARD &&
parameters.getEncryptionMethod() != Zip4jConstants.ENC_METHOD_AES) {
throw new ZipException("unsupported encryption method");
}
if (parameters.getPassword() == null || parameters.getPassword().length <= 0) {
throw new ZipException("input password is empty or null");
}
} else {
parameters.setAesKeyStrength(-1);
parameters.setEncryptionMethod(-1);
}
}
示例2: putNextEntry
import net.lingala.zip4j.model.ZipParameters; //导入方法依赖的package包/类
public void putNextEntry(File file, ZipParameters zipParameters)
throws ZipException {
super.putNextEntry(file, zipParameters);
if (zipParameters.getCompressionMethod() == Zip4jConstants.COMP_DEFLATE) {
deflater.reset();
if ((zipParameters.getCompressionLevel() < 0 || zipParameters
.getCompressionLevel() > 9)
&& zipParameters.getCompressionLevel() != -1) {
throw new ZipException(
"invalid compression level for deflater. compression level should be in the range of 0-9");
}
deflater.setLevel(zipParameters.getCompressionLevel());
}
}