Class NonRestartableInputStreamBuilder

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

    public class NonRestartableInputStreamBuilder
    extends java.lang.Object
    implements InputStreamBuilder
    Creates an InputStreamBuilder from an existing InputStream. The wrapped InputStream will only be read once.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Cleanup any temporary resources associated with the last returned stream.
      java.io.InputStream createInputStream()
      Return a stream in a state where no bytes have been read from it yet.
      long getBytesRead()  
      • Methods inherited from class java.lang.Object

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

      • NonRestartableInputStreamBuilder

        public NonRestartableInputStreamBuilder​(java.io.InputStream in)
        Constructor, a reference to in is kept. Closing of in prior to its use by this class will cause IOException's.
        Parameters:
        in -
      • NonRestartableInputStreamBuilder

        public NonRestartableInputStreamBuilder​(java.io.InputStream in,
                                                boolean close)
        Constructor, a reference to in is kept, with option to keep input stream open. Closing of in prior to its use by this class will cause IOException's.
        Parameters:
        in - the input stream
        close - if true, stream is closed, otherwise kept open
    • Method Detail

      • createInputStream

        public java.io.InputStream createInputStream()
                                              throws java.io.IOException
        Return a stream in a state where no bytes have been read from it yet. For example a newly created stream meets these criteria. The caller should handle closing the stream.
        Specified by:
        createInputStream in interface InputStreamBuilder
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Cleanup any temporary resources associated with the last returned stream.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface InputStreamBuilder
        Throws:
        java.io.IOException
      • getBytesRead

        public long getBytesRead()