Class NotifyingInputStream

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

    class NotifyingInputStream
    extends CountingInputStream
    Input stream which notifies a listener about its progress.
    • Constructor Summary

      Constructors 
      Constructor Description
      NotifyingInputStream​(java.io.InputStream inputStream, long totalSize, java.util.function.Consumer<java.lang.Long> downloadListener)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private long calculateChunkSize​(long totalSize)  
      private void handleRead​(long result)  
      private void notifyListener()  
      int read()  
      int read​(byte[] b, int off, int len)  
      • Methods inherited from class java.io.FilterInputStream

        available, close, markSupported, read
      • Methods inherited from class java.io.InputStream

        nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
      • Methods inherited from class java.lang.Object

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

      • downloadListener

        private final java.util.function.Consumer<java.lang.Long> downloadListener
      • updateChunkSize

        private final long updateChunkSize
      • nextUpdateSize

        private long nextUpdateSize
    • Constructor Detail

      • NotifyingInputStream

        public NotifyingInputStream​(java.io.InputStream inputStream,
                                    long totalSize,
                                    java.util.function.Consumer<java.lang.Long> downloadListener)
    • Method Detail

      • calculateChunkSize

        private long calculateChunkSize​(long totalSize)
      • read

        public int read()
                 throws java.io.IOException
        Overrides:
        read in class CountingInputStream
        Throws:
        java.io.IOException
      • read

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

        private void handleRead​(long result)
      • notifyListener

        private void notifyListener()