Java ByteBuffer Copy copy(ByteBuffer src, int startindex, int endindex)

Here you can find the source of copy(ByteBuffer src, int startindex, int endindex)

Description

copy

License

LGPL

Declaration

public static ByteBuffer copy(ByteBuffer src, int startindex, int endindex) 

Method Source Code


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

import java.nio.ByteBuffer;

public class Main {

    public static ByteBuffer copy(ByteBuffer src, int startindex, int endindex) {
        int size = endindex - startindex;
        ByteBuffer ret = ByteBuffer.allocate(size);
        src.position(startindex);/*from  w  w w. j a v a2 s  .  c o  m*/
        for (int i = 0; i < size; i++) {
            ret.put(src.get());
        }
        return ret;
    }
}

Related

  1. copy(ByteBuffer source)
  2. copy(ByteBuffer source, int byteCount)
  3. copy(ByteBuffer src, ByteBuffer dst)
  4. copy(ByteBuffer src, ByteBuffer dst, int length)
  5. copy(ByteBuffer src, int srcStartindex, ByteBuffer dest, int destStartIndex, int length)
  6. copy(final ByteBuffer from, final ByteBuffer to)
  7. copy2Buffer(byte[] src, int srcOff, int srcLen, ByteBuffer dst, int dstOff)
  8. copyBinary(final ByteBuffer orig)
  9. copyBuffer(ByteBuffer dest, int pos1, ByteBuffer src, int len)