Java ByteBuffer Put writeOutputStream(OutputStream output, ByteBuffer data)

Here you can find the source of writeOutputStream(OutputStream output, ByteBuffer data)

Description

write Output Stream

License

Open Source License

Declaration

public static void writeOutputStream(OutputStream output, ByteBuffer data) 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 final int BUFFER_SIZE = 16384;

    public static void writeOutputStream(OutputStream output, ByteBuffer data) throws IOException {
        byte[] buf = new byte[BUFFER_SIZE];
        for (;;) {
            int rem = data.remaining();
            if (rem == 0)
                break;
            if (rem > buf.length)
                rem = buf.length;//w ww . j a  v a  2 s. c  o m
            data.get(buf, 0, rem);
            output.write(buf, 0, rem);
        }
    }
}

Related

  1. write(ByteBuffer byteBuffer, OutputStream outputStream)
  2. writeByteBufferList(List list, DataOutputStream os)
  3. writeBytes(OutputStream os, ByteBuffer buffer)
  4. writeFully(ByteBuffer buffer, OutputStream os)
  5. writeFully(OutputStream out, ByteBuffer buf)
  6. writeOutputStreamWriter(String str, int offset, int count, OutputStream out, ByteBuffer bytes, CharsetEncoder encoder, Object lock)
  7. writePackedLong(ByteBuffer output, long value)
  8. writeShortByteArray(ByteBuffer name, DataOutput out)
  9. writeTo(ByteBuffer buffer, OutputStream out)