Package ej.hoka.io

Class IdentityMessageBodyOutputStream

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

    public class IdentityMessageBodyOutputStream
    extends java.io.OutputStream
    Identity output stream. Wraps an OutputStream and all of the operations on IdentityMessageBodyOutputStream are delegated to this underlying OutputStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes this output stream and flushes the underlying OutputStream .
      void flush()
      Flushes the underlying output stream.
      void write​(byte[] b)
      Writes the content of the byte array to the underlying output stream.
      void write​(byte[] b, int off, int len)
      Writes len bytes from the specified byte array starting at offset off to this output stream.
      void write​(int b)
      Writes the specified byte to this output stream.
      • 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
    • Constructor Detail

      • IdentityMessageBodyOutputStream

        public IdentityMessageBodyOutputStream​(java.io.OutputStream os)
        Creates a new instance of IdentityMessageBodyOutputStream using the OutputStream as the underlying OutputStream to write the data to.
        Parameters:
        os - the underlying OutputStream to use
    • Method Detail

      • close

        public final void close()
                         throws java.io.IOException
        Closes this output stream and flushes the underlying OutputStream . This method DOES NOT close the underlying stream (i.e. the TCP connection stream). It is the responsibility of the caller to close the underlying stream.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException - when an I/O error occurs while closing the stream
      • flush

        public final void flush()
                         throws java.io.IOException
        Flushes the underlying output stream.
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException - if this output stream has already been closed.
      • write

        public final void write​(byte[] b)
                         throws java.io.IOException
        Writes the content of the byte array to the underlying output stream.
        Overrides:
        write in class java.io.OutputStream
        Parameters:
        b - the byte array to read bytes from and write to the underlying output stream.
        Throws:
        java.io.IOException - if this output stream has already been closed.
      • write

        public final 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 output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation. If b is null, a NullPointerException is thrown. If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.
        Overrides:
        write in class java.io.OutputStream
        Parameters:
        b - the byte array to read bytes from
        off - the starting index in byte array b to read bytes from
        len - number of bytes to read from the byte array b
        Throws:
        java.io.IOException - if this output stream has already been closed
      • write

        public final void write​(int b)
                         throws java.io.IOException
        Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.
        Specified by:
        write in class java.io.OutputStream
        Parameters:
        b - the value to be written to the underlying output stream
        Throws:
        java.io.IOException - if this output stream has already been closed