com.esotericsoftware.kryo.io
Class ByteBufferOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.esotericsoftware.kryo.io.ByteBufferOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class ByteBufferOutputStream
extends java.io.OutputStream

An OutputStream whose target is a ByteBuffer. If bytes would be written that would overflow the buffer, OutputStream.flush() is called. Subclasses can override flush to empty the buffer.


Constructor Summary
ByteBufferOutputStream()
          Creates an uninitialized stream that cannot be used until setByteBuffer(ByteBuffer) is called.
ByteBufferOutputStream(java.nio.ByteBuffer byteBuffer)
           
ByteBufferOutputStream(int bufferSize)
          Creates a stream with a new non-direct buffer of the specified size.
 
Method Summary
 java.nio.ByteBuffer getByteBuffer()
           
 void setByteBuffer(java.nio.ByteBuffer byteBuffer)
           
 void write(byte[] bytes, int offset, int length)
           
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteBufferOutputStream

public ByteBufferOutputStream()
Creates an uninitialized stream that cannot be used until setByteBuffer(ByteBuffer) is called.


ByteBufferOutputStream

public ByteBufferOutputStream(int bufferSize)
Creates a stream with a new non-direct buffer of the specified size.


ByteBufferOutputStream

public ByteBufferOutputStream(java.nio.ByteBuffer byteBuffer)
Method Detail

getByteBuffer

public java.nio.ByteBuffer getByteBuffer()

setByteBuffer

public void setByteBuffer(java.nio.ByteBuffer byteBuffer)

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] bytes,
                  int offset,
                  int length)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException