Class ResumableInputStream

    • Constructor Detail

      • ResumableInputStream

        public ResumableInputStream​(InputStream delegate,
                                    Function<Long,​InputStream> nextInputStreamSupplier)
        Create a new ResumableInputStream
        Parameters:
        delegate - The original InputStream that will be used as a delegate
        nextInputStreamSupplier - A function to create the next InputStream given the number of bytes already read. These inputs can, for example, be used to populate the HTTP Range header. If an unsupported input is provided (more bytes than exist), then a null InputStream should be returned.
    • Method Detail

      • read

        public int read()
                 throws IOException
        If an IOException is thrown by the delegate while reading, the delegate will be recreated and the read will be retried once during this read call.
        Specified by:
        read in class InputStream
        Throws:
        IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws IOException
        If an IOException is thrown by the delegate while reading, the delegate will be recreated and the read will be retried once during this read call.
        Overrides:
        read in class InputStream
        Throws:
        IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len,
                        boolean isRetry)
                 throws IOException
        Throws:
        IOException
      • skip

        public long skip​(long n)
                  throws IOException
        If an IOException is thrown by the delegate while skipping, the delegate will be recreated from the position being skipped to and the return value will be n. This may be longer than the remaining number of bytes, and if so the delegate will be set to a NullInputStream.
        Overrides:
        skip in class InputStream
        Throws:
        IOException
      • mark

        public void mark​(int readlimit)
        Overrides:
        mark in class InputStream