gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-16 14:42:40 25 4
gpt4 key购买 nike

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

ZipFile.extractFile介绍

[英]Extracts a specific file from the zip file to the destination path. This method first finds the necessary file header from the input file name.

File name is relative file name in the zip file. For example if a zip file contains a file "a.txt", then to extract this file, input file name has to be "a.txt". Another example is if there is a file "b.txt" in a folder "abc" in the zip file, then the input file name has to be abc/b.txt

Throws an exception if file header could not be found for the given file name or if the destination path is invalid
[中]将特定文件从zip文件提取到目标路径。此方法首先从输入文件名中查找必要的文件头。
文件名是zip文件中的相对文件名。例如,如果一个zip文件包含一个文件“a.txt”,那么要提取这个文件,输入文件名必须是“a.txt”。另一个例子是,如果zip文件中的“abc”文件夹中有一个文件“b.txt”,那么输入文件名必须是abc/b.txt
如果找不到给定文件名的文件头或目标路径无效,则引发异常

代码示例

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

/**
 * Extracts a specific file from the zip file to the destination path.
 * If destination path is invalid, then this method throws an exception.
 * @param fileHeader
 * @param destPath
 * @throws ZipException
 */
public void extractFile(FileHeader fileHeader, String destPath) throws ZipException {
  extractFile(fileHeader, destPath, null);
}

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

/**
 * Extracts a specific file from the zip file to the destination path.
 * If destination path is invalid, then this method throws an exception.
 * @param fileHeader
 * @param destPath
 * @throws ZipException
 */
public void extractFile(FileHeader fileHeader, String destPath) throws ZipException {
  extractFile(fileHeader, destPath, null);
}

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

/**
 * Extracts a specific file from the zip file to the destination path.
 * If destination path is invalid, then this method throws an exception.
 * <br><br>
 * If newFileName is not null or empty, newly created file name will be replaced by 
 * the value in newFileName. If this value is null, then the file name will be the 
 * value in FileHeader.getFileName
 * @param fileHeader
 * @param destPath
 * @param unzipParameters
 * @throws ZipException
 */
public void extractFile(FileHeader fileHeader, 
    String destPath, UnzipParameters unzipParameters) throws ZipException {
  extractFile(fileHeader, destPath, unzipParameters, null);
}

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

/**
 * Extracts a specific file from the zip file to the destination path.
 * If destination path is invalid, then this method throws an exception.
 * <br><br>
 * If newFileName is not null or empty, newly created file name will be replaced by 
 * the value in newFileName. If this value is null, then the file name will be the 
 * value in FileHeader.getFileName
 * @param fileHeader
 * @param destPath
 * @param unzipParameters
 * @throws ZipException
 */
public void extractFile(FileHeader fileHeader, 
    String destPath, UnzipParameters unzipParameters) throws ZipException {
  extractFile(fileHeader, destPath, unzipParameters, null);
}

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

/**
 * Extracts a specific file from the zip file to the destination path. 
 * This method first finds the necessary file header from the input file name.
 * <br><br>
 * File name is relative file name in the zip file. For example if a zip file contains
 * a file "a.txt", then to extract this file, input file name has to be "a.txt". Another
 * example is if there is a file "b.txt" in a folder "abc" in the zip file, then the
 * input file name has to be abc/b.txt
 * <br><br>
 * Throws an exception if file header could not be found for the given file name or if 
 * the destination path is invalid
 * @param fileName
 * @param destPath
 * @throws ZipException
 */
public void extractFile(String fileName, String destPath) throws ZipException {
  extractFile(fileName, destPath, null);
}

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

/**
 * Extracts a specific file from the zip file to the destination path. 
 * This method first finds the necessary file header from the input file name.
 * <br><br>
 * File name is relative file name in the zip file. For example if a zip file contains
 * a file "a.txt", then to extract this file, input file name has to be "a.txt". Another
 * example is if there is a file "b.txt" in a folder "abc" in the zip file, then the
 * input file name has to be abc/b.txt
 * <br><br>
 * Throws an exception if file header could not be found for the given file name or if 
 * the destination path is invalid
 * @param fileName
 * @param destPath
 * @throws ZipException
 */
public void extractFile(String fileName, String destPath) throws ZipException {
  extractFile(fileName, destPath, null);
}

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

/**
 * Extracts a specific file from the zip file to the destination path. 
 * This method first finds the necessary file header from the input file name.
 * <br><br>
 * File name is relative file name in the zip file. For example if a zip file contains
 * a file "a.txt", then to extract this file, input file name has to be "a.txt". Another
 * example is if there is a file "b.txt" in a folder "abc" in the zip file, then the
 * input file name has to be abc/b.txt
 * <br><br>
 * Throws an exception if file header could not be found for the given file name or if 
 * the destination path is invalid
 * @param fileName
 * @param destPath
 * @param unzipParameters
 * @throws ZipException
 */
public void extractFile(String fileName, 
    String destPath, UnzipParameters unzipParameters) throws ZipException {
  extractFile(fileName, destPath, unzipParameters, null);
}

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

/**
 * Extracts a specific file from the zip file to the destination path. 
 * This method first finds the necessary file header from the input file name.
 * <br><br>
 * File name is relative file name in the zip file. For example if a zip file contains
 * a file "a.txt", then to extract this file, input file name has to be "a.txt". Another
 * example is if there is a file "b.txt" in a folder "abc" in the zip file, then the
 * input file name has to be abc/b.txt
 * <br><br>
 * Throws an exception if file header could not be found for the given file name or if 
 * the destination path is invalid
 * @param fileName
 * @param destPath
 * @param unzipParameters
 * @throws ZipException
 */
public void extractFile(String fileName, 
    String destPath, UnzipParameters unzipParameters) throws ZipException {
  extractFile(fileName, destPath, unzipParameters, null);
}

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

@Override
public void extractTo(DirectoryResource directoryResource)
{
 try
 {
   UnzipParameters parameters = new UnzipParameters();
   getZipFile().extractFile(fileHeader, directoryResource.getFullyQualifiedName(), parameters);
 }
 catch (ZipException e)
 {
   throw new ResourceException("Error while fetching zip contents", e);
 }
}

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

@Override
public void extractTo(DirectoryResource directoryResource, String newName)
{
 try
 {
   UnzipParameters parameters = new UnzipParameters();
   getZipFile().extractFile(fileHeader, directoryResource.getFullyQualifiedName(), parameters, newName);
 }
 catch (ZipException e)
 {
   throw new ResourceException("Error while fetching zip contents", e);
 }
}

代码示例来源:origin: StannyBing/ZXUtils

for (int i = 0; i < zipFile.getFileHeaders().size(); i++) {
  fileHeader = (FileHeader) zipFile.getFileHeaders().get(i);
  zipFile.extractFile(fileHeader, outputPath);
  int progress = (int) ((i + 1) * 1.0 * 100 / total);
  if (progress == progressNow) {//此时与上次相同,就不反复监听了

代码示例来源:origin: visallo/vertexium

private void expandVertexiumPlugin(File vertexiumPluginDir) {
  InputStream zipIn = getClass().getResourceAsStream("/vertexium-elasticsearch5-plugin.zip");
  File pluginZip = new File(vertexiumPluginDir.getParentFile(), "vertexium-elasticsearch5-plugin.zip");
  try (OutputStream zipOut = new FileOutputStream(pluginZip)) {
    IOUtils.copy(zipIn, zipOut);
  } catch (Exception ex) {
    throw new VertexiumException("Could not write plugin zip file", ex);
  }
  try {
    ZipFile zipFile = new ZipFile(pluginZip);
    zipFile.extractFile("elasticsearch/plugin-descriptor.properties", vertexiumPluginDir.getAbsolutePath(), null, "plugin-descriptor.properties");
  } catch (Exception ex) {
    throw new VertexiumException("Could not extract plugin", ex);
  }
  pluginZip.delete();
}

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

if (iof != -1)
      name = name.substring(iof + 1);
    zipFile.extractFile(fileHeader,
        ListWithCustomSetting.getCustomFilesDir(context).getAbsolutePath(),
        null, name);
    try {
      File extractTo = themeManager.getThemePath(UUID.fromString(uuid));
      zipFile.extractFile(fileHeader, extractTo.getParentFile().getAbsolutePath(),
          null, extractTo.getName());
    } catch (IllegalArgumentException e) {
SettingsHelper.deleteSQLiteDatabase(NotificationCountStorage.getFile(context));
try {
  zipFile.extractFile(NOTIFICATION_COUNT_DB_PATH,
      ListWithCustomSetting.getCustomFilesDir(context).getAbsolutePath(),
      null, NotificationCountStorage.getFile(context).getAbsolutePath());

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com