Class TailInputStream

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

    class TailInputStream
    extends java.io.InputStream
    An input stream that tails from a random access file as new input appears there. It's a lousy solution but we don't have access to real interprocess pipes from Java.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean closed  
      private java.io.RandomAccessFile raf  
      private static long TAIL_CHECK_DELAY
      How long to sleep (millis) before checking for updates?
    • Constructor Summary

      Constructors 
      Constructor Description
      TailInputStream​(java.nio.file.Path file)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      boolean markSupported()  
      int read()  
      int read​(byte[] b)  
      int read​(byte[] b, int off, int len)  
      • Methods inherited from class java.io.InputStream

        available, mark, reset, skip
      • Methods inherited from class java.lang.Object

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

      • TAIL_CHECK_DELAY

        private static final long TAIL_CHECK_DELAY
        How long to sleep (millis) before checking for updates?
        See Also:
        Constant Field Values
      • raf

        private java.io.RandomAccessFile raf
      • closed

        private volatile boolean closed
    • Constructor Detail

      • TailInputStream

        public TailInputStream​(java.nio.file.Path file)
                        throws java.io.FileNotFoundException
        Throws:
        java.io.FileNotFoundException
    • Method Detail

      • read

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

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • markSupported

        public boolean markSupported()
        Overrides:
        markSupported in class java.io.InputStream
      • close

        public 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