net.lingala.zip4j.core.ZipFile.addFolder()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中net.lingala.zip4j.core.ZipFile.addFolder()方法的一些代码示例,展示了ZipFile.addFolder()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipFile.addFolder()方法的具体详情如下:
包路径:net.lingala.zip4j.core.ZipFile
类名称:ZipFile
方法名:addFolder

ZipFile.addFolder介绍

[英]Adds the folder in the given file object to the zip file. If zip file does not exist, then a new zip file is created. If input folder is invalid then an exception is thrown. Zip parameters for the files in the folder to be added can be set in the input parameters
[中]将给定文件对象中的文件夹添加到zip文件。如果zip文件不存在,则会创建一个新的zip文件。如果输入文件夹无效,则会引发异常。要添加的文件夹中文件的Zip参数可以在输入参数中设置

代码示例

代码示例来源:origin: net.lingala.zip4j/zip4j

/**
 * Adds the folder in the given path to the zip file. If zip file does not exist, 
 * then a new zip file is created. If input folder path is invalid then an exception
 * is thrown. Zip parameters for the files in the folder to be added can be set in
 * the input parameters
 * @param path
 * @param parameters
 * @throws ZipException
 */
public void addFolder(String path, ZipParameters parameters) throws ZipException {
  if (!Zip4jUtil.isStringNotNullAndNotEmpty(path)) {
    throw new ZipException("input path is null or empty, cannot add folder to zip file");
  }
  
  addFolder(new File(path), parameters);
}

代码示例来源:origin: net.lingala.zip4j/zip4j

/**
 * Adds the folder in the given file object to the zip file. If zip file does not exist, 
 * then a new zip file is created. If input folder is invalid then an exception
 * is thrown. Zip parameters for the files in the folder to be added can be set in
 * the input parameters
 * @param path
 * @param parameters
 * @throws ZipException
 */
public void addFolder(File path, ZipParameters parameters) throws ZipException {
  if (path == null) {
    throw new ZipException("input path is null, cannot add folder to zip file");
  }
  
  if (parameters == null) {
    throw new ZipException("input parameters are null, cannot add folder to zip file");
  }
  
  addFolder(path, parameters, true);
}

代码示例来源:origin: com.github.axet/zip4j

/**
 * Adds the folder in the given file object to the zip file. If zip file does not exist, 
 * then a new zip file is created. If input folder is invalid then an exception
 * is thrown. Zip parameters for the files in the folder to be added can be set in
 * the input parameters
 * @param path
 * @param parameters
 * @throws ZipException
 */
public void addFolder(NativeStorage path, ZipParameters parameters) throws ZipException {
  if (path == null) {
    throw new ZipException("input path is null, cannot add folder to zip file");
  }
  
  if (parameters == null) {
    throw new ZipException("input parameters are null, cannot add folder to zip file");
  }
  
  addFolder(path, parameters, true);
}

代码示例来源:origin: org.apache.apex/apex-engine

public static void createAppPackageFile(File fileToBeCreated, File directory) throws ZipException
{
 ZipFile zipFile = new ZipFile(fileToBeCreated);
 ZipParameters params = new ZipParameters();
 params.setIncludeRootFolder(false);
 zipFile.addFolder(directory, params);
}

代码示例来源:origin: dwatling/apk-decompiler

private void generateZipFile() {
  try {
    File outputFile = new File(this.workFolder.getName() + ".zip");
    if (outputFile.exists()) {
      Logger.info(outputFile.getAbsolutePath() + " already exists. Deleting.");
      outputFile.delete();
    }
    ZipFile output = new net.lingala.zip4j.core.ZipFile(outputFile);
    Logger.info("Generating " + output.getFile().getAbsolutePath());
    ZipParameters params = new ZipParameters();
    params.setIncludeRootFolder(false);
    params.setRootFolderInZip("");
    output.addFolder(this.workFolder.getAbsolutePath() + File.separator + "apktool", params);
    params.setRootFolderInZip("classes");
    output.addFolder(this.workFolder.getAbsolutePath() + File.separator + "classes", params);
  } catch (Throwable t) {
    Logger.error("Unable to generate final zip file.", t);
  }
}

代码示例来源:origin: quanticc/lawena-recording-tool

for (Path path : Arrays.asList(configBackupPath, customBackupPath)) {
  if (Files.exists(path)) {
    zipFile.addFolder(path.toFile(), parameters);

代码示例来源:origin: SpringCloud/spring-cloud-codegen

zipFile.addFolder(srcFile, parameters);
} else {
  zipFile.addFile(srcFile, parameters);

代码示例来源:origin: org.jboss.forge.addon/resources-impl

for (File directory : directories)
 getZipFile().addFolder(directory, parameters);

代码示例来源:origin: org.integratedmodelling/klab-common

/**
 * Create a zip with the passed directory's contents in it. The directory will be the top entry
 * in the file if storeDirectory is true.
 * 
 * @param zipFile
 * @param directory
 * @throws KlabException
 */
public static void zip(File zipFile, File directory, boolean storeDirectory, boolean readHiddenFiles)
    throws KlabException {
  // dest = buildDestinationZipFilePath(srcFile, dest);
  ZipParameters parameters = new ZipParameters();
  // parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); //
  // parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); //
  parameters.setIncludeRootFolder(storeDirectory);
  // parameters.setReadHiddenFiles(readHiddenFiles);
  try {
    ZipFile zipF = new ZipFile(zipFile);
    zipF.addFolder(directory, parameters);
  } catch (ZipException e) {
    throw new KlabIOException(e);
  }
}

代码示例来源:origin: Nepxion/Skeleton

zipFile.addFolder(srcFile, parameters);
} else {
  zipFile.addFile(srcFile, parameters);

代码示例来源:origin: org.openmrs.maven.plugins/openmrs-sdk-maven-plugin

downloadOWAs(targetDirectory, distroProperties, owasDir);
warfile.addFolder(tempDir, new ZipParameters());
try {
  FileUtils.deleteDirectory(tempDir);

代码示例来源:origin: com.github.axet/zip4j

this.zipModel.setSplitLength(splitLength);
addFolder(folderToAdd, parameters, false);

代码示例来源:origin: net.lingala.zip4j/zip4j

this.zipModel.setSplitLength(splitLength);
addFolder(folderToAdd, parameters, false);

相关文章