List of utility methods to do ByteBuffer Put
void | writeFully(OutputStream out, ByteBuffer buf) write Fully buf.mark(); if (buf.hasArray()) { out.write(buf.array(), buf.arrayOffset() + buf.position(), buf.remaining()); } else { byte[] temp = new byte[Math.min(buf.remaining(), 8192)]; while (buf.hasRemaining()) { int w = Math.min(temp.length, buf.remaining()); buf.get(temp, 0, w); ... |
void | writeOutputStream(OutputStream output, ByteBuffer data) write Output Stream byte[] buf = new byte[BUFFER_SIZE]; for (;;) { int rem = data.remaining(); if (rem == 0) break; if (rem > buf.length) rem = buf.length; data.get(buf, 0, rem); ... |
void | writeOutputStreamWriter(String str, int offset, int count, OutputStream out, ByteBuffer bytes, CharsetEncoder encoder, Object lock) write Output Stream Writer assertArrayIndex(str.length(), offset, count); CharBuffer chars = CharBuffer.wrap(str, offset, count + offset); convert(lock, encoder, bytes, chars, out); |
int | writePackedLong(ByteBuffer output, long value) write Packed Long assert value >= 0; int position = output.position(); while (value > 127) { output.put((byte) ((value & 127) + ((value > 127 ? 1 : 0) << 7))); value >>= 7; output.put((byte) (value & 127)); return position; ... |
void | writeShortByteArray(ByteBuffer name, DataOutput out) write Short Byte Array int length = name.remaining(); assert 0 <= length && length <= MAX_UNSIGNED_SHORT; try { out.writeByte((length >> 8) & 0xFF); out.writeByte(length & 0xFF); out.write(name.array(), name.position() + name.arrayOffset(), name.remaining()); } catch (IOException e) { throw new RuntimeException(e); ... |
void | writeTo(ByteBuffer buffer, OutputStream out) write To if (buffer.hasArray()) out.write(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining()); else { byte[] bytes = new byte[TEMP_BUFFER_SIZE]; while (buffer.hasRemaining()) { int byteCountToWrite = Math.min(buffer.remaining(), TEMP_BUFFER_SIZE); buffer.get(bytes, 0, byteCountToWrite); out.write(bytes, 0, byteCountToWrite); ... |
void | writeVarInt(ByteBuffer buffer, int input) write Var Int while ((input & -128) != 0) { buffer.put((byte) (input & 127 | 128)); input >>>= 7; buffer.put((byte) input); |