Java ByteBuffer Get getTerminatedArray(ByteBuffer buf)

Here you can find the source of getTerminatedArray(ByteBuffer buf)

Description

get Terminated Array

License

Open Source License

Declaration

public static byte[] getTerminatedArray(ByteBuffer buf) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;

public class Main {
    public static byte[] getTerminatedArray(ByteBuffer buf) {
        int start = buf.position();

        while (buf.get() != 0) {
        }//from ww w .  j a  va 2  s .  c om
        int end = buf.position();

        byte[] bytes = new byte[end - start - 1]; //don't include terminator
        buf.position(start);
        buf.get(bytes);

        //put position after array
        buf.position(end); //skip terminator

        return bytes;
    }
}

Related

  1. getSmart(ByteBuffer buf)
  2. getSmartOld(ByteBuffer in)
  3. getSurrogateKey(byte[] data, ByteBuffer buffer)
  4. getTableUuid(ByteBuffer rowKey)
  5. getTempByteBuffer()
  6. getTriByte(ByteBuffer buf)
  7. getTruncatedInt(ByteBuffer bytes, int numBytes)
  8. getTsStartSyncByte(ByteBuffer packet, boolean synced)
  9. getTsSyncByte(ByteBuffer packet)