Holger's
Java API

com.antelmann.io
Class MonitorInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.antelmann.io.MonitorInputStream
All Implemented Interfaces:
Closeable

public class MonitorInputStream
extends FilterInputStream

this class is essentially a re-implementation of a ProgressMonitorInputStream, but with a com.antelmann.util.Monitor instead.

Since:
2. März 2007, 20:28
Author:
Holger Antelmann

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
MonitorInputStream(InputStream in)
           
MonitorInputStream(InputStream in, Monitor monitor)
          Constructs an object to monitor the progress of an input stream.
MonitorInputStream(InputStream in, Monitor monitor, boolean maintainSizeAutomatically)
           
 
Method Summary
 void close()
          Overrides FilterInputStream.close to close the monitor as well as the stream.
 Monitor getProgressMonitor()
           
protected  void initSize()
           
 int read()
          Overrides FilterInputStream.read to update the monitor after the read.
 int read(byte[] b)
          Overrides FilterInputStream.read to update the monitor after the read.
 int read(byte[] b, int off, int len)
          Overrides FilterInputStream.read to update the monitor after the read.
 void reset()
          Overrides FilterInputStream.reset to reset the monitor as well as the stream.
 long skip(long n)
          Overrides FilterInputStream.skip to update the monitor after the skip.
protected  void updateMonitor(long bytesRead)
           
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MonitorInputStream

public MonitorInputStream(InputStream in)

MonitorInputStream

public MonitorInputStream(InputStream in,
                          Monitor monitor)
Constructs an object to monitor the progress of an input stream.

Parameters:
in - The input stream to be monitored.

MonitorInputStream

public MonitorInputStream(InputStream in,
                          Monitor monitor,
                          boolean maintainSizeAutomatically)
Method Detail

getProgressMonitor

public Monitor getProgressMonitor()

initSize

protected void initSize()

updateMonitor

protected void updateMonitor(long bytesRead)
                      throws IOException
Throws:
IOException

read

public int read()
         throws IOException
Overrides FilterInputStream.read to update the monitor after the read.

Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException
Overrides FilterInputStream.read to update the monitor after the read.

Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides FilterInputStream.read to update the monitor after the read.

Overrides:
read in class FilterInputStream
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Overrides FilterInputStream.skip to update the monitor after the skip.

Overrides:
skip in class FilterInputStream
Throws:
IOException

close

public void close()
           throws IOException
Overrides FilterInputStream.close to close the monitor as well as the stream.

Specified by:
close in interface Closeable
Overrides:
close in class FilterInputStream
Throws:
IOException

reset

public void reset()
           throws IOException
Overrides FilterInputStream.reset to reset the monitor as well as the stream.

Overrides:
reset in class FilterInputStream
Throws:
IOException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads