Java ByteBuffer Put outputBuffer(ByteBuffer buffer)

Here you can find the source of outputBuffer(ByteBuffer buffer)

Description

output Buffer

License

Open Source License

Declaration

public static void outputBuffer(ByteBuffer buffer) 

Method Source Code

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

import java.io.BufferedOutputStream;
import java.io.File;

import java.io.FileOutputStream;

import java.io.OutputStream;
import java.nio.ByteBuffer;

public class Main {
    private static int frame = 0;

    public static void outputBuffer(ByteBuffer buffer) {
        try {/*from  w  ww. j  a va2s . c o  m*/
            byte[] rawBytes = new byte[buffer.capacity()];
            buffer.get(rawBytes);
            File outputFile = new File(String.format("owf_%04d.bin", frame));
            OutputStream streamOut = new BufferedOutputStream(new FileOutputStream(outputFile));
            streamOut.write(rawBytes);
            streamOut.close();
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }
}

Related

  1. inputStream(ByteBuffer bytes)
  2. inputStreamToByteBuffer(InputStream input)
  3. inputStreamToByteBuffer(InputStream is)
  4. makeInputStream(final ByteBuffer buffer)
  5. moveBufferToStream(OutputStream out, ByteBuffer in, int length)
  6. put(ByteBuffer bb, byte[] bytes, int from)
  7. put(ByteBuffer bb, String s)
  8. put(ByteBuffer bbuf, byte[] post)
  9. put(ByteBuffer buf, String s, String charsetName)