Java ByteBuffer Copy copyToStream(ByteBuffer byteBuffer, OutputStream os)

Here you can find the source of copyToStream(ByteBuffer byteBuffer, OutputStream os)

Description

copy To Stream

License

Open Source License

Declaration

public static void copyToStream(ByteBuffer byteBuffer, OutputStream os) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.io.OutputStream;

import java.nio.ByteBuffer;

public class Main {
    public static void copyToStream(ByteBuffer byteBuffer, OutputStream os) throws IOException {
        byte[] buffer = new byte[32768];
        while (true) {
            int byteCount = Math.min(byteBuffer.remaining(), buffer.length);
            if (byteCount == 0) {
                break;
            }//  www.j  a va2 s.  c o  m

            byteBuffer.get(buffer, 0, byteCount);
            os.write(buffer, 0, byteCount);
        }
    }
}

Related

  1. copyOf(ByteBuffer payload)
  2. copyRemaining(ByteBuffer src, ByteBuffer dst)
  3. copyTo(ByteBuffer original, ByteBuffer copy)
  4. copyToArray(@Nonnull ByteBuffer data)
  5. copyToHeapBuffer(ByteBuffer src, ByteBuffer dest)
  6. copyWholeFrame(ByteBuffer srcFrame, ByteBuffer destFrame)
  7. deepCopy(ByteBuffer orig)
  8. deepCopyByteBufferToByteArray(ByteBuffer byteBuffer)
  9. deepCopyVisible(ByteBuffer orig)