Java Utililty Methods ByteBuffer Put

List of utility methods to do ByteBuffer Put

Description

The list of methods to do ByteBuffer Put are organized into topic(s).

Method

voidwriteFully(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);
...
voidwriteOutputStream(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);
...
voidwriteOutputStreamWriter(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);
intwritePackedLong(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;
...
voidwriteShortByteArray(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);
...
voidwriteTo(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);
...
voidwriteVarInt(ByteBuffer buffer, int input)
write Var Int
while ((input & -128) != 0) {
    buffer.put((byte) (input & 127 | 128));
    input >>>= 7;
buffer.put((byte) input);