/** * Read a byte * * @return byte */ public byte readByte() { verifyRemainingBytes(1); byte value = bytes[nextByte]; nextByte++; return value; }
/** * Read a String from the provided number of bytes * * @param num * number of bytes * @return String * @throws UnsupportedEncodingException */ public String readString(int num) throws UnsupportedEncodingException { verifyRemainingBytes(num); String value = new String(bytes, nextByte, num, CHAR_SET); nextByte += num; return value; }
/** * Read an integer * * @return integer */ public int readInt() { verifyRemainingBytes(4); int value = ByteBuffer.wrap(bytes, nextByte, 4).order(byteOrder) .getInt(); nextByte += 4; return value; }
/** * Read a double * * @return double */ public double readDouble() { verifyRemainingBytes(8); double value = ByteBuffer.wrap(bytes, nextByte, 8).order(byteOrder) .getDouble(); nextByte += 8; return value; }