org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getBytesInflated()方法的使用及代码示例

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

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

ZipArchiveInputStream.getBytesInflated介绍

[英]Get the number of bytes Inflater has actually processed.

for Java < Java7 the getBytes* methods in Inflater/Deflater seem to return unsigned ints rather than longs that start over with 0 at 2^32.

The stream knows how many bytes it has read, but not how many the Inflater actually consumed - it should be between the total number of bytes read for the entry and the total number minus the last read operation. Here we just try to make the value close enough to the bytes we've read by assuming the number of bytes consumed must be smaller than (or equal to) the number of bytes read but not smaller by more than 2^32.
[中]获取充气机实际处理的字节数。
对于Java<Java7,Inflater/Deflater中的getBytes*方法似乎返回无符号整数,而不是以0开头的长整数(2^32)。
流知道它读取了多少字节,但不知道充气机实际消耗了多少字节——它应该介于为条目读取的字节总数和减去上次读取操作的总字节数之间。在这里,我们只是通过假设消耗的字节数必须小于(或等于)读取的字节数,但不小于2^32,来尝试使该值足够接近我们读取的字节数。

代码示例

代码示例来源:origin: org.apache.commons/commons-compress

? getBytesInflated() : current.bytesRead;

代码示例来源:origin: org.apache.commons/commons-compress

/**
 * @since 1.17
 */
@Override
public long getCompressedCount() {
  if (current.entry.getMethod() == ZipArchiveOutputStream.STORED) {
    return current.bytesRead;
  } else if (current.entry.getMethod() == ZipArchiveOutputStream.DEFLATED) {
    return getBytesInflated();
  } else if (current.entry.getMethod() == ZipMethod.UNSHRINKING.getCode()) {
    return ((UnshrinkingInputStream) current.in).getCompressedCount();
  } else if (current.entry.getMethod() == ZipMethod.IMPLODING.getCode()) {
    return ((ExplodingInputStream) current.in).getCompressedCount();
  } else if (current.entry.getMethod() == ZipMethod.ENHANCED_DEFLATED.getCode()) {
    return ((Deflate64CompressorInputStream) current.in).getCompressedCount();
  } else if (current.entry.getMethod() == ZipMethod.BZIP2.getCode()) {
    return ((BZip2CompressorInputStream) current.in).getCompressedCount();
  } else {
    return -1;
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

? getBytesInflated() : current.bytesRead;

相关文章