Java ByteBuffer Copy copyToArray(@Nonnull ByteBuffer data)

Here you can find the source of copyToArray(@Nonnull ByteBuffer data)

Description

copy To Array

License

Open Source License

Declaration

public static byte[] copyToArray(@Nonnull ByteBuffer data) 

Method Source Code


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

import javax.annotation.Nonnull;
import java.nio.ByteBuffer;

public class Main {
    public static byte[] copyToArray(@Nonnull ByteBuffer data) {
        byte[] copy = new byte[data.remaining()];
        data.duplicate().get(copy);/*  w ww .j a v  a 2s .c om*/
        return copy;
    }
}

Related

  1. copyFromBufferToBuffer(ByteBuffer out, ByteBuffer in, int sourceOffset, int length)
  2. copyFromStreamToBuffer(ByteBuffer out, DataInputStream in, int length)
  3. copyOf(ByteBuffer payload)
  4. copyRemaining(ByteBuffer src, ByteBuffer dst)
  5. copyTo(ByteBuffer original, ByteBuffer copy)
  6. copyToHeapBuffer(ByteBuffer src, ByteBuffer dest)
  7. copyToStream(ByteBuffer byteBuffer, OutputStream os)
  8. copyWholeFrame(ByteBuffer srcFrame, ByteBuffer destFrame)
  9. deepCopy(ByteBuffer orig)