List of utility methods to do ByteBuffer Put
void | skipBlank(ByteBuffer input) skip Blank if (input.get() != ' ') { throw new IOException("Parser error reading input from the server: expected a blank space"); |
ByteArrayInputStream | toByteArrayInputStream(ByteBuffer buffer) to Byte Array Input Stream if (buffer.hasArray()) { return new ByteArrayInputStream(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining()); } else { return new ByteArrayInputStream(toBytes(buffer)); |
ByteBuffer | toByteBuffer(InputStream inputStream) to Byte Buffer ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; int l; while ((l = inputStream.read(buffer)) != -1) { baos.write(buffer, 0, l); return ByteBuffer.wrap(baos.toByteArray()); |
ByteBuffer | toByteBuffer(String input) to Byte Buffer return ByteBuffer.wrap(input.getBytes(StandardCharsets.UTF_8));
|
SSLEngineResult | wrap(ByteBuffer byteBuffer, ByteBuffer outputBB, SSLEngine sslEngine) Encrypt bytes. outputBB.clear();
SSLEngineResult result = sslEngine.wrap(byteBuffer, outputBB);
outputBB.flip();
return result;
|
void | write(ByteBuffer buffer, DataOutput out) write if (buffer.hasArray()) { out.write(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining()); } else { for (int i = buffer.position(); i < buffer.limit(); i++) { out.writeByte(buffer.get(i)); |
void | write(ByteBuffer byteBuffer, OutputStream outputStream) Write the contents of the given ByteBuffer into a OutputStream . while (byteBuffer.remaining() > 0) {
outputStream.write(byteBuffer.get());
|
void | writeByteBufferList(List write Byte Buffer List if (list == null) { os.writeInt(-1); return; os.writeInt(list.size()); for (int k = 0; k < list.size(); k++) { writeByteBuffer(list.get(k), os); |
void | writeBytes(OutputStream os, ByteBuffer buffer) Writes the buffer content to the output stream. WritableByteChannel ch = Channels.newChannel(os); ch.write(buffer); |
void | writeFully(ByteBuffer buffer, OutputStream os) Writes all the remaining bytes of the ByteBuffer to the given OutputStream . if (!buffer.hasArray()) { throw new IllegalArgumentException("This only works with buffer that have a backing array"); os.write(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining()); buffer.position(buffer.limit()); |