Java ByteBuffer Clone clone(ByteBuffer original)

Here you can find the source of clone(ByteBuffer original)

Description

clone

License

Apache License

Declaration

public static ByteBuffer clone(ByteBuffer original) 

Method Source Code


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

import java.nio.*;

public class Main {
    public static ByteBuffer clone(ByteBuffer original) {
        ByteBuffer clone = ByteBuffer.allocate(original.capacity());
        original.rewind();//copy from the beginning
        clone.put(original);//  w  w  w  .  ja  va2  s.  com
        original.rewind();
        clone.flip();
        return clone;
    }
}

Related

  1. clone(final ByteBuffer buf)
  2. clone(final ByteBuffer original)
  3. cloneAsDirectByteBuffer(byte[] input, int offset, int len)
  4. cloneBuffer(ByteBuffer pesBuffer)