📄 crcinputstream.java
字号:
// Copyright (C) 1998, 1999, 2001 Chris Nokleberg// Please see included LICENSE.TXTpackage com.sixlegs.image.png;import java.io.FilterInputStream;import java.io.IOException;import java.io.InputStream;import java.util.zip.CRC32;final class CRCInputStreamextends FilterInputStream{ private CRC32 crc = new CRC32(); private int byteCount = 0; public CRCInputStream(InputStream in) { super(in); } public long getValue() { return (long)crc.getValue(); } public void reset() { byteCount = 0; crc.reset(); } public int count() { return byteCount; } public int read() throws IOException { int x = in.read(); if (x != -1) { crc.update(x); byteCount++; } return x; } public int read(byte[] b, int off, int len) throws IOException { int x = in.read(b, off, len); if (x != -1) { crc.update(b, off, x); byteCount += x; } return x; } private byte[] byteArray = new byte[0]; public long skip(long n) throws IOException { // TODO: what if n > Integer.MAX_VALUE ? if (byteArray.length < n) byteArray = new byte[(int)n]; return read(byteArray, 0, (int)n); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -