当前位置: 首页>>代码示例>>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;未经允许,请勿转载。