private int readNextByte(BitInputStream in) throws IOException { long b = in.readBits(8); return (int) b; }
/** * Reads the next code from the stream. * @return the next code * @throws IOException on error */ protected int readNextCode() throws IOException { if (codeSize > 31) { throw new IllegalArgumentException("code size must not be bigger than 31"); } return (int) in.readBits(codeSize); }
private static long readBits(BitInputStream reader, int numBits) throws IOException { long r = reader.readBits(numBits); if (r == -1) { throw new EOFException("Truncated Deflate64 Stream"); } return r; } }
/** * read bits from the input stream * @param n the number of bits to read, must not exceed 32? * @return the requested bits combined into an int * @throws IOException */ private static int bsR(BitInputStream bin, final int n) throws IOException { long thech = bin.readBits(n); if (thech < 0) { throw new IOException("unexpected end of stream"); } return (int) thech; }
public ZCompressorInputStream(final InputStream inputStream, final int memoryLimitInKb) throws IOException { super(inputStream, ByteOrder.LITTLE_ENDIAN); final int firstByte = (int) in.readBits(8); final int secondByte = (int) in.readBits(8); final int thirdByte = (int) in.readBits(8); if (firstByte != MAGIC_1 || secondByte != MAGIC_2 || thirdByte < 0) { throw new IOException("Input is not in .Z format"); } blockMode = (thirdByte & BLOCK_MODE_MASK) != 0; maxCodeSize = thirdByte & MAX_CODE_SIZE_MASK; if (blockMode) { setClearCode(DEFAULT_CODE_SIZE); } initializeTables(maxCodeSize, memoryLimitInKb); clearEntries(); }
private int readNextByte(BitInputStream in) throws IOException { long b = in.readBits(8); return (int) b; }
private static long readBits(BitInputStream reader, int numBits) throws IOException { long r = reader.readBits(numBits); if (r == -1) { throw new EOFException("Truncated Deflate64 Stream"); } return r; } }
/** * Reads the next code from the stream. * @return the next code * @throws IOException on error */ protected int readNextCode() throws IOException { if (codeSize > 31) { throw new IllegalArgumentException("code size must not be bigger than 31"); } return (int) in.readBits(codeSize); }
/** * read bits from the input stream * @param n the number of bits to read, must not exceed 32? * @return the requested bits combined into an int * @throws IOException */ private static int bsR(BitInputStream bin, final int n) throws IOException { long thech = bin.readBits(n); if (thech < 0) { throw new IOException("unexpected end of stream"); } return (int) thech; }
public ZCompressorInputStream(final InputStream inputStream, final int memoryLimitInKb) throws IOException { super(inputStream, ByteOrder.LITTLE_ENDIAN); final int firstByte = (int) in.readBits(8); final int secondByte = (int) in.readBits(8); final int thirdByte = (int) in.readBits(8); if (firstByte != MAGIC_1 || secondByte != MAGIC_2 || thirdByte < 0) { throw new IOException("Input is not in .Z format"); } blockMode = (thirdByte & BLOCK_MODE_MASK) != 0; maxCodeSize = thirdByte & MAX_CODE_SIZE_MASK; if (blockMode) { setClearCode(DEFAULT_CODE_SIZE); } initializeTables(maxCodeSize, memoryLimitInKb); clearEntries(); }