Package org.zkoss.io

Class RepeatableInputStream

java.lang.Object
java.io.InputStream
org.zkoss.io.RepeatableInputStream
All Implemented Interfaces:
Closeable, Serializable, AutoCloseable, Repeatable

public class RepeatableInputStream extends InputStream implements Repeatable, Serializable
RepeatableInputStream adds functionality to another input stream, the ability to read repeatedly. By repeatable-read we mean, after close(), the next invocation of read() will re-open the input stream.

RepeatableInputStream actually creates a temporary space to buffer the content, so it can be re-opened again after closed. Notice that the temporary space (a.k.a., the buffered input stream) is never closed until garbage-collected.

If the content size of the given input stream is smaller than the value specified in the system property called "org.zkoss.io.memoryLimitSize", the content will be buffered in the memory. If the size exceeds, the content will be buffered in a temporary file. By default, it is 512KB. Note: the maximal value is Integer.MAX_VALUE

If the content size of the given input stream is larger than the value specified in the system property called "org.zkoss.io.bufferLimitSize", the content won't be buffered, and it means the read is not repeatable. By default, it is 20MB. Note: the maximal value is Integer.MAX_VALUE

Since:
3.0.4
Author:
jumperchen, tomyeh
See Also: