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

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

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

Archive.readHeaders介绍

[英]Read the headers of the archive
[中]读取归档文件的标题

代码示例

代码示例来源: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);
  }
}

相关文章