Class DuplicatableKeepOpenInputStream

  • All Implemented Interfaces:
    DuplicatableInputStream, Closeable, AutoCloseable

    public class DuplicatableKeepOpenInputStream
    extends KeepOpenInputStream
    implements DuplicatableInputStream
    In Java we cannot specify a type parameter as requiring a type both extend an abstract class, such as InputStream and implement an interface such as DuplicatableInputStream.

    As such we are in the unenviable position of needing to accept a parameter and then check its type.

    • Constructor Detail

      • DuplicatableKeepOpenInputStream

        public DuplicatableKeepOpenInputStream​(InputStream is)
        Creates a KeepOpenInputStream while retaining its marking as a DuplicatableInputStream
        Parameters:
        is - The DuplicatableInputStream that will be kept open. This is checked with instanceof.
    • Method Detail

      • duplicate

        public InputStream duplicate()
        Description copied from interface: DuplicatableInputStream
        Produces a duplicate stream of the source (from its start) that can be used in parallel to the original stream (ie, thread safe).
        Specified by:
        duplicate in interface DuplicatableInputStream
        Returns:
        A new input stream instance.