List of utility methods to do ByteBuffer Write
void | writeLong(long num, ByteBuffer out) write Long for (int i = 0; i < 8; i++) { out.put((byte) num); num >>>= 8; |
void | writeLong(long v, ByteBuffer buffer) write Long buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putLong(v); buffer.order(ByteOrder.BIG_ENDIAN); |
void | writeLTriad(int triad, ByteBuffer bb) write L Triad bb.put(writeLTriad(triad)); |
void | writeNullTerminatedString(ByteBuffer buf, String s, String encoding) write Null Terminated String buf.put(s.getBytes(encoding));
buf.put((byte) 0);
|
void | writePackageName(ByteBuffer buffer, String packageName) Writes the provided package name to the buffer in UTF-16. buffer.put(packageName.getBytes(Charset.forName("UTF-16LE")), 0, PACKAGE_NAME_SIZE);
|
void | writeRemaining(WritableByteChannel channel, ByteBuffer buffer) write Remaining int noopCountDown = MAX_NOOP_TRIALS; while (buffer.hasRemaining()) { if (channel.write(buffer) == 0) { if (--noopCountDown == 0) throw new IOException("Write failed after " + MAX_NOOP_TRIALS + " trials"); continue; noopCountDown = MAX_NOOP_TRIALS; ... |
void | writeResBit15(int value, ByteBuffer toBuffer) write Res Bit if (value < 0x80) { toBuffer.put((byte) value); } else { toBuffer.putShort((short) (value | 0x8000)); |
void | writeShortString(ByteBuffer buffer, String s) Write a size prefixed string where the size is stored as a 2 byte short if (s == null) { buffer.putShort((short) -1); } else if (s.length() > Short.MAX_VALUE) { throw new IllegalArgumentException("String exceeds the maximum size of " + Short.MAX_VALUE + "."); } else { byte[] data = getBytes(s); buffer.putShort((short) data.length); buffer.put(data); ... |
void | writeSign(ByteBuffer bb) write Sign bb.put(SIGN); |
void | writeSignedVarint(ByteBuffer buffer, int val) Write an signed integer using a variable-length encoding. writeUnsignedVarint(buffer, (val << 1) ^ (val >> 31)); |