transfer Remaining ByteBuffer - Java java.nio

Java examples for java.nio:ByteBuffer Remain

Description

transfer Remaining ByteBuffer

Demo Code


//package com.java2s;
import java.nio.ByteBuffer;

public class Main {
    public static int transferRemaining(ByteBuffer src, ByteBuffer trg) {
        int xfer = Math.min(src.remaining(), trg.remaining());
        int oldLimit = src.limit();
        src.limit(src.position() + xfer);
        trg.put(src);/*from   w w  w  .  ja  v  a 2  s.  c  om*/
        src.limit(oldLimit);
        return xfer;
    }
}

Related Tutorials