/** Read an unsigned short from the buffer. */ private int readUnsignedShort() throws IOException, InterruptedException { if (curr > used - 2) { readMore(2); } final int val = ((buf[curr] & 0xff) << 8) | (buf[curr + 1] & 0xff); curr += 2; return val; }
/** Read a long from the buffer. */ @SuppressWarnings("unused") private long readLong() throws IOException, InterruptedException { if (curr > used - 8) { readMore(8); } final long val = (((long) (((buf[curr] & 0xff) << 24) | ((buf[curr + 1] & 0xff) << 16) | ((buf[curr + 2] & 0xff) << 8) | (buf[curr + 3] & 0xff))) << 32) | ((buf[curr + 4] & 0xff) << 24) | ((buf[curr + 5] & 0xff) << 16) | ((buf[curr + 6] & 0xff) << 8) | (buf[curr + 7] & 0xff); curr += 8; return val; }
/** Skip the given number of bytes in the input stream. */ private void skip(final int bytesToSkip) throws IOException, InterruptedException { if (curr > used - bytesToSkip) { readMore(bytesToSkip); } curr += bytesToSkip; }
/** Read an unsigned byte from the buffer. */ private int readUnsignedByte() throws IOException, InterruptedException { if (curr > used - 1) { readMore(1); } return buf[curr++] & 0xff; }
/** Read an int from the buffer. */ private int readInt() throws IOException, InterruptedException { if (curr > used - 4) { readMore(4); } final int val = ((buf[curr] & 0xff) << 24) | ((buf[curr + 1] & 0xff) << 16) | ((buf[curr + 2] & 0xff) << 8) | (buf[curr + 3] & 0xff); curr += 4; return val; }