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

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

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

ZipFile.addFile介绍

[英]Adds input source file to the zip file. If zip file does not exist, then this method creates a new zip file. Parameters such as compression type, etc can be set in the input parameters.
[中]将输入源文件添加到zip文件。如果zip文件不存在,则此方法将创建一个新的zip文件。可以在输入参数中设置压缩类型等参数。

代码示例

代码示例来源:origin: de.alpharogroup/file-worker

/**
 * Adds the given file(s) to the given zip file.
 *
 * @param zipFile4j
 *            the zip file4j
 * @param parameters
 *            the parameters
 * @param toAdd
 *            the list with the files to add in the zip file
 * @throws ZipException
 *             the zip exception
 */
public static void zipFiles(final ZipFile zipFile4j, final ZipParameters parameters,
  final List<File> toAdd) throws ZipException
{
  for (final File element : toAdd)
  {
    zipFile4j.addFile(element, parameters);
  }
}

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

zipFile.addFile(srcFile, parameters);

代码示例来源:origin: io.macgyver/macgyver-core

} catch (Exception e) {
mj.addFile(f, zp);

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

zipFile.addFile(srcFile, parameters);

代码示例来源:origin: jclehner/rxdroid

zip.addFile(file, zp);

代码示例来源:origin: com.tomitribe.tribestream/tribestream-container

for (final File f : content.files) {
  zip.addFile(f, parameters);

代码示例来源:origin: MCMrARM/revolution-irc

zipFile.addFile(f, params);
    synchronized (ServerCertificateManager.get(sslCertsFile)) { // lock the helper to prevent any writes to the file
      params.setFileNameInZip(BACKUP_SERVER_CERTS_PREFIX + data.uuid + BACKUP_SERVER_CERTS_SUFFIX);
      zipFile.addFile(sslCertsFile, params);
zipFile.addFile(NotificationCountStorage.getFile(context), params);
NotificationCountStorage.getInstance(context).open();
for (ThemeInfo themeInfo : themeManager.getCustomThemes()) {
  params.setFileNameInZip(BACKUP_THEME_PREFIX + themeInfo.uuid + BACKUP_THEME_SUFFIX);
  zipFile.addFile(themeManager.getThemePath(themeInfo.uuid), params);

代码示例来源:origin: com.jalalkiswani/jk-util

/**
 * Compress.
 *
 * @param fileName
 *            the file name
 * @param compressedFileName
 *            the compressed file name
 * @param password
 *            the password
 */
public static void compress(String fileName, String compressedFileName, String password) {
  try {
    ZipParameters zipParameters = new ZipParameters();
    zipParameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
    zipParameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_ULTRA);
    if (password != null) {
      zipParameters.setEncryptFiles(true);
      zipParameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_AES);
      zipParameters.setAesKeyStrength(Zip4jConstants.AES_STRENGTH_256);
      zipParameters.setPassword(password);
    }
    String destinationZipFilePath = compressedFileName;
    ZipFile zipFile = new ZipFile(destinationZipFilePath);
    zipFile.addFile(new File(fileName), zipParameters);
  } catch (ZipException e) {
    JKExceptionUtil.handle(e);
  }
}

相关文章