當前位置: 首頁>>代碼示例>>Java>>正文


Java ZipParameters.isEncryptFiles方法代碼示例

本文整理匯總了Java中net.lingala.zip4j.model.ZipParameters.isEncryptFiles方法的典型用法代碼示例。如果您正苦於以下問題:Java ZipParameters.isEncryptFiles方法的具體用法?Java ZipParameters.isEncryptFiles怎麽用?Java ZipParameters.isEncryptFiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.lingala.zip4j.model.ZipParameters的用法示例。


在下文中一共展示了ZipParameters.isEncryptFiles方法的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);
	}
	
}
 
開發者ID:joielechong,項目名稱:Zip4jAndroid,代碼行數:33,代碼來源:ZipEngine.java

示例2: calculateTotalWork

import net.lingala.zip4j.model.ZipParameters; //導入方法依賴的package包/類
private long calculateTotalWork(ArrayList fileList, ZipParameters parameters) throws ZipException {
	if (fileList == null) {
		throw new ZipException("file list is null, cannot calculate total work");
	}
	
	long totalWork = 0;
	
	for (int i = 0; i < fileList.size(); i++) {
		if(fileList.get(i) instanceof File) {
			if (((File)fileList.get(i)).exists()) {
				if (parameters.isEncryptFiles() && 
						parameters.getEncryptionMethod() == Zip4jConstants.ENC_METHOD_STANDARD) {
					totalWork += (Zip4jUtil.getFileLengh((File)fileList.get(i)) * 2);
				} else {
					totalWork += Zip4jUtil.getFileLengh((File)fileList.get(i));
				}
				
				if (zipModel.getCentralDirectory() != null && 
						zipModel.getCentralDirectory().getFileHeaders() != null && 
						zipModel.getCentralDirectory().getFileHeaders().size() > 0) {
					String relativeFileName = Zip4jUtil.getRelativeFileName(
							((File)fileList.get(i)).getAbsolutePath(), parameters.getRootFolderInZip(), parameters.getDefaultFolderPath());
					FileHeader fileHeader = Zip4jUtil.getFileHeader(zipModel, relativeFileName);
					if (fileHeader != null) {
						totalWork += (Zip4jUtil.getFileLengh(new File(zipModel.getZipFile())) - fileHeader.getCompressedSize());
					}
				}
			}
		}
	}
	
	return totalWork;
}
 
開發者ID:joielechong,項目名稱:Zip4jAndroid,代碼行數:34,代碼來源:ZipEngine.java


注:本文中的net.lingala.zip4j.model.ZipParameters.isEncryptFiles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。