Class DynamicBufferedOutputStream

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

    public class DynamicBufferedOutputStream
    extends java.io.FilterOutputStream
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void flush()
      Flushes this buffered output stream.
      void write​(byte[] b, int off, int len)
      Writes len bytes from the specified byte array starting at offset off to this buffered output stream.
      void write​(int b)
      Writes the specified byte to this buffered output stream.
      • Methods inherited from class java.io.FilterOutputStream

        close, write
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_MAX_BUFFER_SIZE

        protected static final int DEFAULT_MAX_BUFFER_SIZE
        See Also:
        Constant Field Values
      • buf

        protected byte[] buf
      • count

        protected int count
    • Constructor Detail

      • DynamicBufferedOutputStream

        public DynamicBufferedOutputStream​(java.io.OutputStream out,
                                           int extendSize,
                                           int maxSize)
      • DynamicBufferedOutputStream

        public DynamicBufferedOutputStream​(java.io.OutputStream out)
      • DynamicBufferedOutputStream

        public DynamicBufferedOutputStream​(java.io.OutputStream out,
                                           int size)
    • Method Detail

      • write

        public void write​(int b)
                   throws java.io.IOException
        Writes the specified byte to this buffered output stream.
        Overrides:
        write in class java.io.FilterOutputStream
        Parameters:
        b - the byte to be written.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Writes len bytes from the specified byte array starting at offset off to this buffered output stream.

        Ordinarily this method stores bytes from the given array into this stream's buffer, flushing the buffer to the underlying output stream as needed. If the requested length is at least as large as this stream's buffer, however, then this method will flush the buffer and write the bytes directly to the underlying output stream. Thus redundant BufferedOutputStreams will not copy data unnecessarily.

        Overrides:
        write in class java.io.FilterOutputStream
        Parameters:
        b - the data.
        off - the start offset in the data.
        len - the number of bytes to write.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • flush

        public void flush()
                   throws java.io.IOException
        Flushes this buffered output stream. This forces any buffered output bytes to be written out to the underlying output stream.
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.FilterOutputStream
        Throws:
        java.io.IOException - if an I/O error occurs.
        See Also:
        FilterOutputStream.out