Java ByteBuffer to Byte Array toByteArray(ByteBuffer buffer)

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

Description

to Byte Array

License

Apache License

Declaration

public static byte[] toByteArray(ByteBuffer buffer) 

Method Source Code

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

import java.nio.ByteBuffer;

import java.util.Map;

public class Main {
    public static byte[] toByteArray(ByteBuffer buffer) {
        byte[] ret = new byte[buffer.remaining()];
        buffer.get(ret, 0, ret.length);//from w  w w.ja v a 2  s  .  co  m
        return ret;
    }

    public static <S, T> T get(Map<S, T> m, S key, T def) {
        T ret = m.get(key);
        if (ret == null) {
            ret = def;
        }
        return ret;
    }
}

Related

  1. toArray(ByteBuffer bytebuffer)
  2. toArray(final ByteBuffer b)
  3. toArray(final ByteBuffer buffer)
  4. toByteArray(ByteBuffer bb)
  5. toByteArray(ByteBuffer buf)
  6. toByteArray(ByteBuffer buffer)
  7. toByteArray(ByteBuffer buffer)
  8. toByteArray(ByteBuffer buffer)
  9. toByteArray(ByteBuffer buffer, int length)