Java Utililty Methods ByteBuffer Fill

List of utility methods to do ByteBuffer Fill

Description

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

Method

voidfill(ByteBuffer buffer, int off, int len, byte val)
fill
buffer.position(off);
while (--len >= 0)
    buffer.put(val);
voidfill(ByteBuffer buffer, int position, int length, byte filler)
fill
if (buffer.hasArray())
    Arrays.fill(buffer.array(), position, length, filler);
else {
    for (int i = position; i < length; i++) {
        buffer.put(filler);
intfill(ByteBuffer to, byte[] b, int off, int len)
Like append, but does not throw BufferOverflowException
int pos = flipToFill(to);
try {
    int remaining = to.remaining();
    int take = remaining < len ? remaining : len;
    to.put(b, off, take);
    return take;
} finally {
    flipToFlush(to, pos);
...
BufferfillBuffer(ByteBuffer buffer, byte[] bytes)
fill Buffer
for (byte b : bytes) {
    buffer.put(b);
return buffer;
voidfillBuffer(ByteBuffer buffer, int seed)
fill Buffer
Random rnd = new Random(seed);
while (buffer.remaining() != 0)
    buffer.putInt(rnd.nextInt());
buffer.rewind();
voidfillBufFromTime(ByteBuffer buf, Calendar cal)
fill Buf From Time
buf.putChar((char) cal.get(Calendar.YEAR));
buf.put((byte) (cal.get(Calendar.MONTH) + 1));
buf.put((byte) cal.get(Calendar.DAY_OF_MONTH));
buf.put((byte) cal.get(Calendar.HOUR_OF_DAY));
buf.put((byte) cal.get(Calendar.MINUTE));
buf.put((byte) cal.get(Calendar.SECOND));
ByteBufferfillDdsBuffer(ByteBuffer buf)
fill Dds Buffer
buf.rewind();
buf.putInt(ddsNumber);
buf.put((byte) (ddsAcknowledged ? 1 : 0));
buf.putInt(ddsDescription.length());
for (int i = 0; i < ddsDescription.length(); i++) {
    buf.putChar(ddsDescription.charAt(i));
buf.putFloat(ddsPrecision);
...
ByteBufferfillHlaBuffer(ByteBuffer buf)
fill Hla Buffer
String name = hlaName;
int messageLength = 1 + 4 + 4 + 2 * name.length();
if (messageLength > MAX_BUFFER_SIZE) {
    int extraMessageLength = messageLength - MAX_BUFFER_SIZE;
    name = name.substring(0, name.length() - (extraMessageLength / 2));
buf.rewind();
buf.put((byte) (hlaOk ? 1 : 0));
...
voidfillRange(ByteBuffer buffer, int start, int end)
Sets all bits in the given byte range to 1.
putRange(buffer, start, end, (byte) 0xff);