Here you can find the source of clone(ByteBuffer original)
public static ByteBuffer clone(ByteBuffer original)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static ByteBuffer clone(ByteBuffer original) { ByteBuffer clone = ByteBuffer.allocate(original.capacity()); original.rewind();//from w w w. jav a 2 s. c om clone.put(original); original.rewind(); clone.flip(); return clone; } }