Java examples for java.nio:ByteBuffer
transfer one ByteBuffer to another ByteBuffer
//package com.java2s; import java.nio.ByteBuffer; public class Main { public static int transfer(ByteBuffer src, ByteBuffer dst) { int numBytes = Math.min(src.remaining(), dst.remaining()); if (numBytes > 0) { int oldLimit = src.limit(); src.limit(src.position() + numBytes); dst.put(src);/*from ww w.j ava 2s . co m*/ src.limit(oldLimit); } return numBytes; } }