The list of methods to do ByteBuffer Append are organized into topic(s).
byte[]
append(ByteBuffer source, int index, byte[] dest) append
if (source == null || source.remaining() == 0)
return dest;
int byteCount = source.remaining();
int requiredCapacity = index + byteCount;
if (requiredCapacity > dest.length) {
byte[] newArray = new byte[requiredCapacity];
System.arraycopy(dest, 0, newArray, 0, dest.length);
dest = newArray;
...
StringBuilder
appendHex(StringBuilder sb, ByteBuffer bb) append Hex
int limit = bb.limit();
for (int i = bb.position(); i < limit; i++) {
int c = bb.get(i) & 0xff;
sb.append(Character.forDigit(c >> 4, 16));
sb.append(Character.forDigit(c & 0xf, 16));
if (i < limit - 1)
sb.append(' ');
return sb;
ByteBuffer
appendLong(long value, ByteBuffer buffer) Append long to the end of the buffer, possibly reallocating it.
if (buffer.remaining() < 8)
buffer = grow(buffer, MIN_REMAINING);
buffer.putLong(value);
return buffer;
ByteBuffer
appendOrRealloc(ByteBuffer dest, ByteBuffer toAppend) Appends the contents of toAppend to dest if there is capacity, or does the equivalent of C's "realloc" by allocating a larger buffer and copying both dest and toAppend into that new buffer.
if (dest.capacity() - dest.position() < toAppend.limit()) {
ByteBuffer newDest = ByteBuffer.allocate(dest.capacity() << 1);
dest.flip();
newDest.put(dest);
dest = newDest;
dest.put(toAppend);
return dest;
...
void
appendSurrogate(ByteBuffer bb, char c) Append
%Uxxxx to the given byte buffer.
bb.put((byte) '%');
bb.put((byte) 'U');
bb.put(HEX_DIGITS[(c >> 12) & 0x0f]);
bb.put(HEX_DIGITS[(c >> 8) & 0x0f]);
bb.put(HEX_DIGITS[(c >> 4) & 0x0f]);
bb.put(HEX_DIGITS[c & 0x0f]);
void
appendToEnd(final File file, final ByteBuffer contents) Append the specified byte buffer to the end of the specified file
FileChannel fileChannel = null;
try {
fileChannel = new FileOutputStream(file, true).getChannel();
fileChannel.write(contents);
contents.rewind();
} catch (IOException e) {
e.printStackTrace();
} finally {
...