Java Utililty Methods ByteBuffer Set

List of utility methods to do ByteBuffer Set

Description

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

Method

intfindCommonPrefix(ByteBuffer buffer, int offsetLeft, int offsetRight, int limit)
Find length of common prefix of two parts in the buffer
int prefix = 0;
for (; prefix < limit; ++prefix) {
    if (buffer.get(offsetLeft + prefix) != buffer.get(offsetRight + prefix)) {
        break;
return prefix;
ByteBufferfrom(ByteBuffer buffer, int offset)
from
ByteBuffer dup = buffer.duplicate();
dup.position(dup.position() + offset);
return dup;
SetfromListToSetByteArray(List list)
from List To Set Byte Array
Set<byte[]> set = new TreeSet<byte[]>(new Comparator<byte[]>() {
    @Override
    public int compare(byte[] left, byte[] right) {
        return compareTo(left, 0, left.length, right, 0, right.length);
    public int compareTo(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2,
            int length2) {
        if (buffer1 == buffer2 && offset1 == offset2 && length1 == length2) {
...
voidget(ByteBuffer srcBuffer, byte[] dstBytes, int dstOffset, int length)
get
if (srcBuffer.hasArray()) {
    if (length > srcBuffer.remaining()) {
        throw new BufferUnderflowException();
    System.arraycopy(srcBuffer.array(), srcBuffer.arrayOffset() + srcBuffer.position(), dstBytes, dstOffset,
            length);
    srcBuffer.position(srcBuffer.position() + length);
} else {
...
StringgetCharsetFromDocument(ByteBuffer bb)
Get charset from a document.
String patternMeta = "(?i)<meta\\s([^>]*)>";
Pattern pm = Pattern.compile(patternMeta);
Matcher mm;
try {
    mm = pm.matcher(new String(bb.array(), fallbackCharset));
} catch (Exception e) {
    e.printStackTrace();
    return null;
...
booleangetEquals(ByteBuffer buf, String s, String charsetName)
Gets a String that is the same length as the given string starting at the buffer's current position, advances the position by the same length, and compares the two strings for equality.
return s.equals(getString(buf, s.length(), charsetName));
intgetSignedInt(ByteBuffer buffer, int offset)
Reads a big-endian signed integer from the buffer and advances position.
return (buffer.get(offset) & 0xFF) << 24 | (buffer.get(offset + 1) & 0xFF) << 16
        | (buffer.get(offset + 2) & 0xFF) << 8 | buffer.get(offset + 3) & 0xFF;
voidhash_murmur3_128(ByteBuffer buf, int offset, int size, int i, byte[] result)
hasmurmu_
booleanisFree(int frameIx, int offset, ByteBuffer[] frames)
is Free
return ((((frames[frameIx]).array()[offset]) & 0x80) == 0x80);
StringmacAddressToString(ByteBuffer packet, int offset, boolean needHyphen)
mac Address To String
if (packet == null)
    return "";
if (packet.limit() < offset + 6)
    throw new IllegalArgumentException();
String format = needHyphen ? "%02X-%02X-%02X-%02X-%02X-%02X" : "%02X%02X%02X%02X%02X%02X";
return String.format(format, packet.get(offset), packet.get(offset + 1), packet.get(offset + 2),
        packet.get(offset + 3), packet.get(offset + 4), packet.get(offset + 5));