Here you can find the source of getByteBufferOutputStream(final ByteBuffer buf)
Parameter | Description |
---|---|
buf | a parameter |
public static OutputStream getByteBufferOutputStream(final ByteBuffer buf)
//package com.java2s; /**//from ww w.ja va 2 s . c om * Copyright (C) 2010-2011, FuseSource Corp. All rights reserved. * * http://fusesource.com * * The software in this package is published under the terms of the * CDDL license a copy of which has been included with this distribution * in the license.txt file. */ import java.io.*; import java.nio.ByteBuffer; public class Main { /** * Create an OutputStream for a ByteBuffer * * @param buf * @return */ public static OutputStream getByteBufferOutputStream(final ByteBuffer buf) { return new OutputStream() { public void write(int b) throws IOException { buf.put((byte) b); } public void write(byte[] bytes, int off, int len) throws IOException { buf.put(bytes, off, len); } }; } }