Class InputStreamWrapper

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class InputStreamWrapper
    extends Object
    implements Closeable
    A wrapped input stream. It may wrap a regular file, the standard input stream, or any other InputStream instance. This wrapper is intended to wrap InputStream instances for use with CloseableRegistry, hence such instances should not be closed directly, that is, without going through the wrapper's close() method.
    Since:
    0.5.0
    Version:
    $Id: InputStreamWrapper.java 16154 2012-07-14 16:34:05Z colin $
    Author:
    tlerios@marketcetera.com
    • Field Detail

      • mSkipClose

        private boolean mSkipClose
    • Constructor Detail

      • InputStreamWrapper

        public InputStreamWrapper​(String name)
                           throws FileNotFoundException
        Creates a new wrapped stream that wraps the regular file with the given name, or the standard input stream (if the name is SpecialNames.STANDARD_INPUT).
        Parameters:
        name - The file name.
        Throws:
        FileNotFoundException - Thrown if the name represents a regular file, and it cannot be opened for reading.
      • InputStreamWrapper

        public InputStreamWrapper​(File file)
                           throws FileNotFoundException
        Creates a new wrapped stream that wraps the given regular file.
        Parameters:
        file - The file.
        Throws:
        FileNotFoundException - Thrown if the file cannot be opened for reading.
      • InputStreamWrapper

        public InputStreamWrapper​(InputStream stream,
                                  boolean skipClose)
        Creates a new wrapped stream that wraps the given stream. The stream may or may not be closed when close() is called depending on the given flag.
        Parameters:
        stream - The stream.
        skipClose - True if the underlying stream should not be closed.
      • InputStreamWrapper

        public InputStreamWrapper​(InputStream stream)
        Creates a new wrapped stream that wraps the given stream. The underlying stream will be closed when close() is called; hence the given stream should not wrap (or be) the standard input stream.
        Parameters:
        stream - The stream.
    • Method Detail

      • getStream

        public InputStream getStream()
        Returns the receiver's underlying stream.
        Returns:
        The stream.
      • getSkipClose

        public boolean getSkipClose()
        Returns true if the receiver's underlying stream will not be closed when close() is called.
        Returns:
        True if so.