Class NoThrowInputStream

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

    public final class NoThrowInputStream
    extends java.io.InputStream
    Wraps an existing input stream, converting all the underlying stream's IOExceptions to our own NoThrowInputStream.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
      NoThrowInputStream​(java.io.InputStream underlying)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      long getBytesRead()  
      int read()  
      int read​(byte[] b)  
      int read​(byte[] b, int off, int len)  
      • Methods inherited from class java.io.InputStream

        available, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

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

      • NoThrowInputStream

        public NoThrowInputStream​(java.io.InputStream 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.InputStream
      • read

        public int read()
        Specified by:
        read in class java.io.InputStream
      • read

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

        public int read​(byte[] b)
        Overrides:
        read in class java.io.InputStream
      • getBytesRead

        public long getBytesRead()