com.googlecode.d2j.util.zip.ZipFile.readCentralDir()方法的使用及代码示例

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

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

ZipFile.readCentralDir介绍

[英]Find the central directory and read the contents.

The central directory can be followed by a variable-length comment field, so we have to scan through it backwards. The comment is at most 64K, plus we have 18 bytes for the end-of-central-dir stuff itself, plus apparently sometimes people throw random junk on the end just for the fun of it.

This is all a little wobbly. If the wrong value ends up in the EOCD area, we're hosed. This appears to be the way that everybody handles it though, so we're in good company if this fails.
[中]找到中心目录并阅读内容。
中央目录后面可以跟一个可变长度的注释字段,所以我们必须向后扫描它。评论最多64K,加上我们有18个字节作为central dir内容本身的结尾,而且显然有时候人们只是为了好玩而在结尾随意扔垃圾。
这一切都有点不稳定。如果EOCD区域出现错误的值,我们将被冲洗。不过,这似乎是每个人处理问题的方式,所以如果失败了,我们会有很好的伙伴关系。

代码示例

代码示例来源:origin: pxb1988/dex2jar

public ZipFile(ByteBuffer in) throws IOException {
  raf = in.asReadOnlyBuffer().order(ByteOrder.LITTLE_ENDIAN);
  readCentralDir();
}

代码示例来源:origin: pxb1988/dex2jar

public ZipFile(File fd) throws IOException {
  RandomAccessFile randomAccessFile = new RandomAccessFile(fd, "r");
  file = randomAccessFile;
  raf = randomAccessFile.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, fd.length());
  readCentralDir();
}

代码示例来源:origin: SparkInLee/dexdiff

public ZipFile(ByteBuffer in) throws IOException {
  raf = in.asReadOnlyBuffer().order(ByteOrder.LITTLE_ENDIAN);
  readCentralDir();
}

代码示例来源:origin: SparkInLee/dexdiff

public ZipFile(File fd) throws IOException {
  RandomAccessFile randomAccessFile = new RandomAccessFile(fd, "r");
  file = randomAccessFile;
  raf = randomAccessFile.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, fd.length());
  readCentralDir();
}

相关文章