Java ByteBuffer Clone cloneByteBufferList(List source)

Here you can find the source of cloneByteBufferList(List source)

Description

clone Byte Buffer List

License

Open Source License

Declaration

public static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source) 

Method Source Code


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

import java.nio.ByteBuffer;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source) {
        List<ByteBuffer> ret = new ArrayList<ByteBuffer>(source.size());
        for (int k = 0; k < source.size(); k++) {
            ret.add(cloneByteBuffer(source.get(k)));
        }//from   w  w w.  j ava 2 s . c om
        return ret;
    }

    public static ByteBuffer cloneByteBuffer(ByteBuffer buf) {
        ByteBuffer ret = ByteBuffer.allocate(buf.limit() - buf.position());
        ret.put(buf);
        ret.flip();
        buf.flip();
        return ret;
    }
}

Related

  1. cloneAsDirectByteBuffer(byte[] input, int offset, int len)
  2. cloneBuffer(ByteBuffer pesBuffer)
  3. cloneBufferData(ByteBuffer srcBuffer)
  4. cloneByteBuffer(ByteBuffer buf)
  5. cloneByteBuffer(ByteBuffer buf)
  6. cloneByteBufferList(List source)
  7. cloneOnHeap(final ByteBuffer buf)
  8. cloneSection(ByteBuffer source, int start, int count)