List of utility methods to do ByteBuffer Clear
void | clear(ByteBuffer b) clear b.reset(); b.limit(b.capacity()); |
void | clear(ByteBuffer buffer) Clear the buffer to be empty in flush mode. if (buffer != null) {
buffer.position(0);
buffer.limit(0);
|
void | clear(ByteBuffer buffer, int position, int length, byte filler) clear assert buffer != null;
prepare(buffer, position, length);
fill(buffer, position, buffer.limit(), filler);
|
void | clear(ByteBuffer[] buffers) clear if (buffers == null) { return; for (ByteBuffer buffer : buffers) { if (buffer != null) { buffer.clear(); |
void | clearAll(ByteBuffer[] buffers) Convenience method to clear array of buffers. for (int i = buffers.length; i-- > 0;) buffers[i].clear(); |
ByteBuffer | clearAndEnsureCapacity(ByteBuffer buffer, int elements) Ensure the buffer's capacity is large enough to hold a given number of elements. if (buffer == null || buffer.capacity() < elements) { buffer = ByteBuffer.allocate(elements); } else { buffer.clear(); return buffer; |
void | clearRemaining(ByteBuffer buffer) Sets all bits in the given remaining byte range to 0. if (!buffer.hasRemaining()) { return; int pos = buffer.position(); clearRange(buffer, pos, pos + buffer.remaining()); |
void | clearRemainingFrame(ByteBuffer buffer, int position) clear Remaining Frame buffer.array()[position] = 0; |
void | clearString(ByteBuffer buffer) clear String byte[] data = new byte[buffer.capacity()]; for (int i = 0; i < data.length; i++) { data[i] = '0'; buffer.clear(); buffer.put(data); buffer.clear(); |
boolean | fillBuffer(ReadableByteChannel channel, ByteBuffer buf, boolean clear) fill Buffer if (clear) { buf.clear(); while (true) { int cnt = channel.read(buf); if (cnt < 0) { return false; if (buf.position() == buf.capacity()) { break; return true; |