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


Java ZipParameters.setDefaultFolderPath方法代碼示例

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


在下文中一共展示了ZipParameters.setDefaultFolderPath方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: zip

import net.lingala.zip4j.model.ZipParameters; //導入方法依賴的package包/類
/**
 * Adds a directory to a ZIP-archive.
 *
 * @param source      directory to compress, will not be added itself;
 *                    source directory child files will be placed in the root of archive
 * @param destination ZIP-archive
 * @param level       compression level (0-9)
 * @param skipFilter  skipped files filter or {@code null} to accept all files
 * @throws IOException if any I/O-exception occured
 */
public static void zip(File source, File destination, int level, @Nullable FileFilter skipFilter)
        throws IOException {
    try {
        ZipParameters parameters = new ZipParameters();
        parameters.setIncludeRootFolder(false);
        parameters.setCompressionLevel(level);
        parameters.setReadHiddenFiles(true);
        parameters.setDefaultFolderPath(source.getAbsolutePath());

        ZipFile zipFile = new ZipFile(destination);
        zipFile.addFiles(deepListFilesInDirectory(source, skipFilter, !parameters.isReadHiddenFiles()), parameters);
    } catch (ZipException e) {
        throw new IOException("Can't add directory to ZIP-file.", e);
    }
}
 
開發者ID:Codeforces,項目名稱:codeforces-commons,代碼行數:26,代碼來源:ZipUtil.java

示例2: zipFiles

import net.lingala.zip4j.model.ZipParameters; //導入方法依賴的package包/類
@Override
public String zipFiles(String zipFilePath, List<File> files, String filesRootPath, boolean includeRootPath) {

    String errorMessage = null;
    ZipParameters parameters = new ZipParameters();
    parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
    parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_FAST);
    parameters.setEncryptionMethod(Zip4jConstants.ENC_NO_ENCRYPTION);
    parameters.setDefaultFolderPath(filesRootPath);
    parameters.setIncludeRootFolder(includeRootPath);

    try {
        ZipFile zipFile = new ZipFile(zipFilePath);

        for (int i = 0; i < files.size(); i++) {
            File file = files.get(i);
            if (file.isFile()) {
                zipFile.addFile(file, parameters);
            }
            if (file.isDirectory()) {
                zipFile.addFolder(file, parameters);
            }
        }
    } catch (ZipException e) {
        errorMessage = e.getMessage();
    }

    return errorMessage;
}
 
開發者ID:rndsolutions,項目名稱:hawkcd,代碼行數:30,代碼來源:FileManagementService.java

示例3: zipFiles

import net.lingala.zip4j.model.ZipParameters; //導入方法依賴的package包/類
@Override
public String zipFiles(String zipFilePath, List<File> files, String filesRootPath, boolean includeRootPath) {

    String errorMessage = null;
    ZipParameters parameters = new ZipParameters();
    parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
    parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_FAST);
    parameters.setEncryptionMethod(Zip4jConstants.ENC_NO_ENCRYPTION);
    parameters.setDefaultFolderPath(filesRootPath);
    parameters.setIncludeRootFolder(includeRootPath);

    try {
        ZipFile zipFile = new ZipFile(zipFilePath);


        for (int i = 0; i < files.size(); i++) {
            File file = files.get(i);
            if (file.isFile()) {
                zipFile.addFile(file, parameters);
            }
            if (file.isDirectory()) {
                zipFile.addFolder(file, parameters);
            }
        }
    } catch (ZipException e) {
        e.printStackTrace();
    }

    return errorMessage;
}
 
開發者ID:rndsolutions,項目名稱:hawkcd,代碼行數:31,代碼來源:FileManagementService.java

示例4: writeZip

import net.lingala.zip4j.model.ZipParameters; //導入方法依賴的package包/類
void writeZip(File pkgFile, File packageFolder) throws ZipException {
    ZipFile zipFile = new ZipFile(pkgFile);
    ZipParameters zipParameters = new ZipParameters();
    zipParameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD);
    zipParameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
    zipParameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
    zipParameters.setIncludeRootFolder(false);
    zipParameters.setDefaultFolderPath(packageFolder.getAbsolutePath());
    zipFile.addFiles(listZipFiles(packageFolder), zipParameters);
}
 
開發者ID:proarc,項目名稱:proarc,代碼行數:11,代碼來源:CejshBuilder.java

示例5: addFolderToZip

import net.lingala.zip4j.model.ZipParameters; //導入方法依賴的package包/類
public void addFolderToZip(File file, ZipParameters parameters, 
		ProgressMonitor progressMonitor, boolean runInThread) throws ZipException {
	if (file == null || parameters == null) {
		throw new ZipException("one of the input parameters is null, cannot add folder to zip");
	}
	
	if (!Zip4jUtil.checkFileExists(file.getAbsolutePath())) {
		throw new ZipException("input folder does not exist");
	}
	
	if (!file.isDirectory()) {
		throw new ZipException("input file is not a folder, user addFileToZip method to add files");
	}
	
	if (!Zip4jUtil.checkFileReadAccess(file.getAbsolutePath())) {
		throw new ZipException("cannot read folder: " + file.getAbsolutePath());
	}
	
	String rootFolderPath = null;
	if (parameters.isIncludeRootFolder()) {
		if (file.getAbsolutePath() != null) {
			rootFolderPath = file.getAbsoluteFile().getParentFile() != null ? file.getAbsoluteFile().getParentFile().getAbsolutePath() : "";
		} else {
			rootFolderPath = file.getParentFile() != null ? file.getParentFile().getAbsolutePath() : "";
		}
	} else {
	    rootFolderPath = file.getAbsolutePath();
	}
	
	parameters.setDefaultFolderPath(rootFolderPath);
	
	ArrayList fileList = Zip4jUtil.getFilesInDirectoryRec(file, parameters.isReadHiddenFiles());
	
	if (parameters.isIncludeRootFolder()) {
		if (fileList == null) {
			fileList = new ArrayList();
		}
		fileList.add(file);
	}
	
	addFiles(fileList, parameters, progressMonitor, runInThread);
}
 
開發者ID:joielechong,項目名稱:Zip4jAndroid,代碼行數:43,代碼來源:ZipEngine.java


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