Package com.jalios.io
Class MonitoredInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.io.BufferedInputStream
-
- com.jalios.io.MonitoredInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class MonitoredInputStream extends java.io.BufferedInputStreamA BufferedInputStream that count bytes read to display the status of the stream.- Author:
- Jean-Philippe
-
-
Field Summary
Fields Modifier and Type Field Description protected longmaxlengthprotected longreadlengthprotected longstartingTime
-
Constructor Summary
Constructors Constructor Description MonitoredInputStream(java.io.InputStream stream, int size, long maxlength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetMaxLength()Returns the maxLength of the inputStreamlonggetSpentTime(boolean elapse)Return the time spent into this output streamlonggetStatus(boolean absolute, boolean done)Return the status of the stream.intread()Delegate Read to super class, count charactere read.intread(byte[] b, int off, int len)Delegate Read to super class, count charactere read.-
Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, reset, skip
-
-
-
-
Method Detail
-
read
public int read() throws java.io.IOExceptionDelegate Read to super class, count charactere read.- Overrides:
readin classjava.io.BufferedInputStream- Throws:
java.io.IOException- See Also:
InputStream.read()
-
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionDelegate Read to super class, count charactere read.- Overrides:
readin classjava.io.BufferedInputStream- Throws:
java.io.IOException- See Also:
InputStream.read(byte[], int, int)
-
getStatus
public long getStatus(boolean absolute, boolean done)Return the status of the stream. How many bytes have been read.- Parameters:
absolute- if return an absolute value or percentagedone- if return the available byte or done bytes- Returns:
- long the status of the stream
-
getSpentTime
public long getSpentTime(boolean elapse)
Return the time spent into this output stream- Parameters:
elapse- true return time spent, false return time to spent- Returns:
- the duration
- Since:
- jcms-4.2
-
getMaxLength
public long getMaxLength()
Returns the maxLength of the inputStream- Returns:
- the maxLength of the inputStream
-
-