com.github.junrar.Archive.close()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(113)

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

Archive.close介绍

[英]Close the underlying compressed file.
[中]关闭基础压缩文件。

代码示例

代码示例来源:origin: edmund-wagner/junrar

@Override
protected void doCloseCommunicationLink() {
  try {
    archive.close();
  } catch (FileSystemException e) {
    throw new RuntimeException(e);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

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

@Override
protected void doCloseCommunicationLink() {
  try {
    this.archive.close();
  } catch (final FileSystemException e) {
    throw new RuntimeException(e);
  } catch (final IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: apache/tika

} finally {
  if (rar != null)
    rar.close();

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

private static List<File> extractArchiveTo(final Archive arch, final ExtractDestination destination) throws IOException, RarException {
  if (arch.isEncrypted()) {
    logger.warn("archive is encrypted cannot extract");
    arch.close();
    return new ArrayList<File>();
  }
  final List<File> extractedFiles = new ArrayList<File>();
  try{
    for(final FileHeader fh : arch ) {
      try {
        final File file = tryToExtract(logger, destination, arch, fh);
        if (file != null) {
          extractedFiles.add(file);
        }
      } catch (final IOException e) {
        logger.error("error extracting the file", e);
        throw e;
      } catch (final RarException e) {
        logger.error("error extraction the file", e);
        throw e;
      }
    }
  }finally {
    arch.close();
  }
  return extractedFiles;
}

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

public static List<ContentDescription> getContentsDescription(final File rar) throws RarException, IOException {
  validateRarPath(rar);
  final Archive arch = createArchiveOrThrowException(logger, rar);
  final List<ContentDescription> contents = new ArrayList<ContentDescription>();
  try{
    if (arch.isEncrypted()) {
      logger.warn("archive is encrypted cannot extract");
      return new ArrayList<ContentDescription>();
    }
    for(final FileHeader fileHeader : arch ) {
      contents.add(new ContentDescription(fileHeader.getFileNameString(), fileHeader.getUnpSize()));
    }
  }finally {
    arch.close();
  }
  return contents;
}

代码示例来源:origin: edmund-wagner/junrar

private void setFile(IReadOnlyAccess file, long length) throws IOException {
  totalPackedSize = 0L;
  totalPackedRead = 0L;
  close();
  rof = file;
  try {
    readHeaders(length);
  } catch (Exception e) {
    logger.log(Level.WARNING,
        "exception in archive constructor maybe file is encrypted "
            + "or currupt", e);
    // ignore exceptions to allow exraction of working files in
    // corrupt archive
  }
  // Calculate size of packed data
  for (BaseBlock block : headers) {
    if (block.getHeaderType() == UnrarHeadertype.FileHeader) {
      totalPackedSize += ((FileHeader) block).getFullPackSize();
    }
  }
  if (unrarCallback != null) {
    unrarCallback.volumeProgressChanged(totalPackedRead,
        totalPackedSize);
  }
}

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

private void setFile(final IReadOnlyAccess file, final long length) throws IOException, RarException {
  this.totalPackedSize = 0L;
  this.totalPackedRead = 0L;
  close();
  this.rof = file;
  try {
    readHeaders(length);
  } catch (final Exception e) {
    logger.warn( "exception in archive constructor maybe file is encrypted, corrupt or support not yet implemented", e);
    // Rethrow unsupportedRarException
    if (e instanceof RarException && ((RarException) e).getType() == RarExceptionType.unsupportedRarArchive) {
      throw (RarException) e;
    }
    // ignore exceptions to allow extraction of working files in
    // corrupt archive
  }
  // Calculate size of packed data
  for (final BaseBlock block : this.headers) {
    if (block.getHeaderType() == UnrarHeadertype.FileHeader) {
      this.totalPackedSize += ((FileHeader) block).getFullPackSize();
    }
  }
  if (this.unrarCallback != null) {
    this.unrarCallback.volumeProgressChanged(this.totalPackedRead,
        this.totalPackedSize);
  }
}

代码示例来源:origin: com.github.lafa.tikaNoExternal/tika-parsers

} finally {
  if (rar != null)
    rar.close();

代码示例来源:origin: org.apache.tika/tika-parsers

} finally {
  if (rar != null)
    rar.close();

相关文章