Java Utililty Methods ByteBuffer Write

List of utility methods to do ByteBuffer Write

Description

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

Method

voidwrite(ByteBuffer bb, int elementWidth, long value)
write
if (bb.order() == ByteOrder.BIG_ENDIAN) {
    value = swap(elementWidth, value);
writeBE(bb, elementWidth, value);
voidwrite(ByteBuffer data, String filename, boolean append)
write
File file = new File(filename);
file.getParentFile().mkdirs();
write(data, file, append);
voidwrite(final byte[] array, final int offset, final int end, final ByteBuffer outBB)
write
byte b;
for (int i = offset; i < end; i++) {
    b = array[i];
    if (b == '|') {
        outBB.put((byte) ',').put((byte) ' ');
    } else if (b == '\'') {
        boolean found = false;
        while (++i < end) {
...
longwrite(GatheringByteChannel out, ByteBuffer[] buffers, int offset, int length)
A gathering write utility wrapper.
long total = 0;
write: while (length > 0) {
    long wrote = out.write(buffers, offset, length);
    if (wrote == 0)
        break;
    total += wrote;
    for (int i = offset; i < buffers.length; i++) {
        if (buffers[i].hasRemaining()) {
...
voidwrite(MappedByteBuffer buffer, int pos, String asciString)
write
byte[] bytes = asciString.getBytes();
for (int i = 0; i < bytes.length; ++i) {
    buffer.put(pos + i, bytes[i]);
intwrite(SocketChannel channel, ByteBuffer b, PrimitiveIterator.OfInt iterator)
write
int bytesToWrite = iterator.hasNext() ? iterator.nextInt() : ALL;
bytesToWrite = bytesToWrite == ALL ? b.remaining() : bytesToWrite;
int limit = b.limit();
b.limit(b.position() + bytesToWrite);
int written = channel.write(b);
b.limit(limit);
return written;
voidwrite(SocketChannel p_channel, SSLEngine p_sslEngine, ByteBuffer p_outAppBuf, ByteBuffer p_outNetBuf)
write
assert p_outNetBuf.limit() == p_outNetBuf.capacity();
while (p_outAppBuf.hasRemaining()) {
    final SSLEngineResult l_res;
    l_res = p_sslEngine.wrap(p_outAppBuf, p_outNetBuf);
    switch (l_res.getStatus()) {
    case OK:
    case BUFFER_OVERFLOW:
        p_outNetBuf.flip();
...
voidwrite(WritableByteChannel channel, ByteBuffer buffer, byte[] data)
write
buffer.clear();
int remaining = data.length;
int limit = buffer.limit();
if (remaining < limit) {
    buffer.put(data);
    buffer.flip();
    channel.write(buffer);
    buffer.clear();
...
longwrite(WritableByteChannel channel, ByteBuffer[] srcs)
write
if (channel instanceof GatheringByteChannel) {
    GatheringByteChannel gbc = (GatheringByteChannel) channel;
    return gbc.write(srcs);
long count = 0;
for (ByteBuffer buf : srcs) {
    if (!buf.hasRemaining()) {
        continue;
...
longwrite(WritableByteChannel channel, ByteBuffer[] srcs, int offset, int length)
GatheringChannel support.
long res = 0;
for (int ii = 0; ii < length; ii++) {
    ByteBuffer bb = srcs[ii + offset];
    if (bb.hasRemaining()) {
        res += channel.write(bb);
        if (bb.hasRemaining()) {
            break;
return res;