Class RawMonitorInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    DefaultFileContent.RawFileContentInputStream

    public class RawMonitorInputStream
    extends java.io.FilterInputStream
    An InputStream that provides end-of-stream monitoring.

    This is the same as MonitorInputStream but without the buffering.

    Since:
    2.5.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.atomic.AtomicLong atomicCount  
      private static int EOF_CHAR  
      private java.util.concurrent.atomic.AtomicBoolean finished  
      • Fields inherited from class java.io.FilterInputStream

        in
    • Constructor Summary

      Constructors 
      Constructor Description
      RawMonitorInputStream​(java.io.InputStream inputStream)
      Constructs a MonitorInputStream from the passed InputStream
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      Returns 0 if the stream is at EOF, else the underlying inputStream will be queried.
      void close()
      Closes this input stream and releases any system resources associated with the stream.
      long getCount()
      Gets the number of bytes read by this input stream.
      void mark​(int readlimit)  
      protected void onClose()
      Called after the stream has been closed.
      int read()
      Reads a character.
      int read​(byte[] buffer, int offset, int length)
      Reads bytes from this input stream.
      • Methods inherited from class java.io.FilterInputStream

        markSupported, read, reset, skip
      • Methods inherited from class java.lang.Object

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

      • finished

        private final java.util.concurrent.atomic.AtomicBoolean finished
      • atomicCount

        private final java.util.concurrent.atomic.AtomicLong atomicCount
    • Constructor Detail

      • RawMonitorInputStream

        public RawMonitorInputStream​(java.io.InputStream inputStream)
        Constructs a MonitorInputStream from the passed InputStream
        Parameters:
        inputStream - The input stream to wrap.
    • Method Detail

      • available

        public int available()
                      throws java.io.IOException
        Returns 0 if the stream is at EOF, else the underlying inputStream will be queried.
        Overrides:
        available in class java.io.FilterInputStream
        Returns:
        The number of bytes that are available.
        Throws:
        java.io.IOException - if an error occurs.
      • read

        public int read()
                 throws java.io.IOException
        Reads a character.
        Overrides:
        read in class java.io.FilterInputStream
        Returns:
        The character that was read as an integer.
        Throws:
        java.io.IOException - if an error occurs.
      • read

        public int read​(byte[] buffer,
                        int offset,
                        int length)
                 throws java.io.IOException
        Reads bytes from this input stream.
        Overrides:
        read in class java.io.FilterInputStream
        Parameters:
        buffer - A byte array in which to place the characters read.
        offset - The offset at which to start reading.
        length - The maximum number of bytes to read.
        Returns:
        The number of bytes read.
        Throws:
        java.io.IOException - if an error occurs.
      • close

        public void close()
                   throws java.io.IOException
        Closes this input stream and releases any system resources associated with the stream.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.FilterInputStream
        Throws:
        java.io.IOException - if an error occurs.
      • onClose

        protected void onClose()
                        throws java.io.IOException
        Called after the stream has been closed. This implementation does nothing.
        Throws:
        java.io.IOException - if an error occurs.
      • getCount

        public long getCount()
        Gets the number of bytes read by this input stream.
        Returns:
        The number of bytes read by this input stream.
      • mark

        public void mark​(int readlimit)
        Overrides:
        mark in class java.io.FilterInputStream