Class SlicedInputStream

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

    public abstract class SlicedInputStream
    extends java.io.InputStream
    A SlicedInputStream is a logical concatenation one or more input streams. In contrast to the JDKs SequenceInputStream this stream doesn't require the instantiation of all logical sub-streams ahead of time. Instead, openSlice(long) is called if a new slice is required. Each slice is closed once it's been fully consumed or if close is called before.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected SlicedInputStream​(long numSlices)
      Creates a new SlicedInputStream
    • Method Summary

      Modifier and Type Method Description
      int available()  
      void close()  
      protected abstract java.io.InputStream openSlice​(long slice)
      Called for each logical slice given a zero based slice ordinal.
      int read()  
      int read​(byte[] buffer, int offset, int length)  
      • Methods inherited from class java.io.InputStream

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

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

      • SlicedInputStream

        protected SlicedInputStream​(long numSlices)
        Creates a new SlicedInputStream
        Parameters:
        numSlices - the number of slices to consume
    • Method Detail

      • openSlice

        protected abstract java.io.InputStream openSlice​(long slice)
                                                  throws java.io.IOException
        Called for each logical slice given a zero based slice ordinal.
        Throws:
        java.io.IOException
      • read

        public final int read()
                       throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public final int read​(byte[] buffer,
                              int offset,
                              int length)
                       throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • close

        public final void close()
                         throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException
      • available

        public final int available()
                            throws java.io.IOException
        Overrides:
        available in class java.io.InputStream
        Throws:
        java.io.IOException