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

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

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

ZipFile.getEntryDataStart介绍

暂无

代码示例

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

/**
 * Returns an input stream on the data of the specified {@code android.ZipEntry}.
 * 
 * @param entry
 *            the android.ZipEntry.
 * @return an input stream of the data contained in the {@code android.ZipEntry}.
 * @throws java.io.IOException
 *             if an {@code IOException} occurs.
 * @throws IllegalStateException
 *             if this zip file has been closed.
 */
public InputStream getInputStream(ZipEntry entry) throws IOException {
  long entryDataStart = getEntryDataStart(entry);
  ByteBuffer is = (ByteBuffer) raf.duplicate().position((int) entryDataStart);
  if (entry.compressionMethod == ZipEntry.STORED) {
    final ByteBuffer buf = (ByteBuffer) is.slice().order(ByteOrder.LITTLE_ENDIAN).limit((int) entry.size);
    return new ByteBufferBackedInputStream(buf);
  } else {
    final ByteBuffer buf = (ByteBuffer) is.slice().order(ByteOrder.LITTLE_ENDIAN)
        .limit((int) entry.compressedSize);
    int bufSize = Math.max(1024, (int) Math.min(entry.getSize(), 65535L));
    return new ZipInflaterInputStream(new ByteBufferBackedInputStream(buf), new Inflater(true), bufSize, entry);
  }
}

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

/**
 * Returns an input stream on the data of the specified {@code android.ZipEntry}.
 * 
 * @param entry
 *            the android.ZipEntry.
 * @return an input stream of the data contained in the {@code android.ZipEntry}.
 * @throws java.io.IOException
 *             if an {@code IOException} occurs.
 * @throws IllegalStateException
 *             if this zip file has been closed.
 */
public InputStream getInputStream(ZipEntry entry) throws IOException {
  long entryDataStart = getEntryDataStart(entry);
  ByteBuffer is = (ByteBuffer) raf.duplicate().position((int) entryDataStart);
  if (entry.compressionMethod == ZipEntry.STORED) {
    final ByteBuffer buf = (ByteBuffer) is.slice().order(ByteOrder.LITTLE_ENDIAN).limit((int) entry.size);
    return new ByteBufferBackedInputStream(buf);
  } else {
    final ByteBuffer buf = (ByteBuffer) is.slice().order(ByteOrder.LITTLE_ENDIAN)
        .limit((int) entry.compressedSize);
    int bufSize = Math.max(1024, (int) Math.min(entry.getSize(), 65535L));
    return new ZipInflaterInputStream(new ByteBufferBackedInputStream(buf), new Inflater(true), bufSize, entry);
  }
}

相关文章