Java ByteBuffer Get get(ByteBuffer buffer)

Here you can find the source of get(ByteBuffer buffer)

Description

get

License

Apache License

Declaration

public static byte[] get(ByteBuffer buffer) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.nio.Buffer;
import java.nio.ByteBuffer;
import javax.annotation.Nonnegative;

public class Main {
    public static byte[] get(ByteBuffer buffer) {
        byte[] data = new byte[buffer.limit()];

        buffer.get(data);/*ww  w. ja  v a 2  s . co  m*/

        return data;
    }

    public static <T extends Buffer> T limit(T buffer, @Nonnegative int limit) {
        return limit(buffer, limit, false);
    }

    @SuppressWarnings({ "unchecked" })
    public static <T extends Buffer> T limit(T buffer, int limit, boolean adjustToBounds) {
        return ((T) buffer.limit((adjustToBounds ? Math.min(Math.max(limit, 0), buffer.capacity()) : limit)));
    }
}

Related

  1. calculateNewLength(ByteBuffer source, ByteBuffer target)
  2. get(ByteBuffer source)
  3. get3ByteInt(ByteBuffer buffer)
  4. getActiveArray(ByteBuffer buffer)
  5. getAddress(ByteBuffer buf)