Class BufferedMessageOutputStream

    • Field Detail

      • out

        protected OutputStream out
        The underlying output stream.
    • Constructor Detail

      • BufferedMessageOutputStream

        public BufferedMessageOutputStream()
                                    throws IOException
        Creates a new output stream to write data to an unspecified underlying output stream through a buffer with default size.
        Throws:
        IOException - if the internal ObjectOutputStream cannot be correctly initialized.
      • BufferedMessageOutputStream

        public BufferedMessageOutputStream​(int size)
                                    throws IOException
        Creates a new output stream to write data to an unspecified underlying output stream through a buffer with the specified size.
        Parameters:
        size - the buffer size.
        Throws:
        IllegalArgumentException - if size is less than 0.
        IOException - if the internal ObjectOutputStream cannot be correctly initialized.
    • Method Detail

      • drain

        private final void drain()
                          throws IOException
        Writes the internal buffer in underlying output stream.
        Throws:
        IOException - an error occurs.
      • write

        public final void write​(int b)
                         throws IOException
        Writes the specified byte to this output stream.
        Specified by:
        write in class MessageOutputStream
        Parameters:
        b - the byte to be written.
        Throws:
        IOException - if an I/O error occurs.
      • write

        public final void write​(byte[] b,
                                int off,
                                int len)
                         throws IOException
        Writes len bytes from the specified byte array starting at offset off to this 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.

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

        public final void flush()
                         throws IOException
        Flushes this output stream.

        This forces any buffered output bytes to be written out to the underlying output stream.

        Specified by:
        flush in interface Flushable
        Overrides:
        flush in class OutputStream
        Throws:
        IOException - if an I/O error occurs.