Class ByteBufferOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    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.
    Author:
    Nathan Sweet
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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, nullOutputStream, 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