Class NoThrowOutputStream

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

    public final class NoThrowOutputStream
    extends java.io.OutputStream
    Wraps an existing output stream, converting all the underlying stream's IOExceptions to our own NoThrowOutputStream.HiddenException, which is a subclass of RuntimeException. This means that the methods don't have IOException in their throws clauses.

    NOTE: The name is slightly misleading in that these methods still might throw an IOException wrapped in a HiddenException, just not an IOException directly.

    Also, it does have IOException in the throws clause of close(), but you're not supposed to call that method.

    • Constructor Summary

      Constructors 
      Constructor Description
      NoThrowOutputStream​(java.io.OutputStream underlying)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void flush()  
      long getBytesWritten()  
      void write​(byte[] b)  
      void write​(byte[] b, int off, int len)  
      void write​(int b)  
      • 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

      • NoThrowOutputStream

        public NoThrowOutputStream​(java.io.OutputStream underlying)
    • Method Detail

      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
      • flush

        public void flush()
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
        Overrides:
        write in class java.io.OutputStream
      • write

        public void write​(byte[] b)
        Overrides:
        write in class java.io.OutputStream
      • write

        public void write​(int b)
        Specified by:
        write in class java.io.OutputStream
      • getBytesWritten

        public long getBytesWritten()