|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Reader
org.zkoss.io.RepeatableReader
public class RepeatableReader
RepeatableReader adds functionality to another reader,
the ability to read repeatedly.
By repeatable-read we mean, after close(), the next invocation of
read(char[], int, int) will re-open the reader.
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 reader)
is never closed until garbage-collected.
If the content size of the given reader 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 reader 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
| Field Summary |
|---|
| Fields inherited from class java.io.Reader |
|---|
lock |
| Method Summary | |
|---|---|
void |
close()
Closes the current access, and the next call of read(char[], int, int)
re-opens the buffered reader. |
protected void |
finalize()
|
static java.io.Reader |
getInstance(java.io.File file)
Returns a reader to read a file, encoded in UTF-8, that can be read repeatedly. |
static java.io.Reader |
getInstance(java.io.File file,
java.lang.String charset)
Returns a reader to read a file that can be read repeatedly. |
static java.io.Reader |
getInstance(java.io.Reader rd)
Returns a reader that can be read repeatedly, or null if the given reader is null. |
static java.io.Reader |
getInstance(java.lang.String filename)
Returns a reader to read a file, encoded in UTF-8, that can be read repeatedly. |
static java.io.Reader |
getInstance(java.lang.String filename,
java.lang.String charset)
Returns a reader to read a file that can be read repeatedly. |
static java.io.Reader |
getInstance(java.net.URL url)
Returns a reader to read the resource of the specified URL, encoded in UTF-8. |
static java.io.Reader |
getInstance(java.net.URL url,
java.lang.String charset)
Returns a reader to read the resource of the specified URL. |
int |
read(char[] cbuf,
int off,
int len)
|
| Methods inherited from class java.io.Reader |
|---|
mark, markSupported, read, read, read, ready, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.io.Reader getInstance(java.io.Reader rd)
close() is called.
By repeatable-read we mean, after close(), the next
invocation of read(char[], int, int) will re-open the reader.
Use this method instead of instantiating RepeatableReader
with the constructor.
getInstance(File)
public static java.io.Reader getInstance(java.io.File file,
java.lang.String charset)
throws java.io.FileNotFoundException
By repeatable-read we mean, after close(), the next
invocation of read(char[], int, int) will re-open the reader.
Note: it is efficient since we don't have to buffer the content of the file to make it repeatable-read.
charset - the charset. If null, "UTF-8" is assumed.
java.lang.IllegalArgumentException - if file is null.
java.io.FileNotFoundExceptiongetInstance(Reader),
getInstance(String, String)
public static java.io.Reader getInstance(java.io.File file)
throws java.io.FileNotFoundException
By repeatable-read we mean, after close(), the next
invocation of read(char[], int, int) will re-open the reader.
Note: it is efficient since we don't have to buffer the content of the file to make it repeatable-read.
java.lang.IllegalArgumentException - if file is null.
java.io.FileNotFoundExceptiongetInstance(Reader),
getInstance(String)
public static java.io.Reader getInstance(java.lang.String filename,
java.lang.String charset)
throws java.io.FileNotFoundException
By repeatable-read we mean, after close(), the next
invocation of read(char[], int, int) will re-open the reader.
Note: it is efficient since we don't have to buffer the content of the file to make it repeatable-read.
filename - the file namecharset - the charset. If null, "UTF-8" is assumed.
java.lang.IllegalArgumentException - if file is null.
java.io.FileNotFoundException - if file is not found.getInstance(Reader),
getInstance(File, String)
public static java.io.Reader getInstance(java.lang.String filename)
throws java.io.FileNotFoundException
By repeatable-read we mean, after close(), the next
invocation of read(char[], int, int) will re-open the reader.
Note: it is efficient since we don't have to buffer the content of the file to make it repeatable-read.
filename - the file name
java.lang.IllegalArgumentException - if file is null.
java.io.FileNotFoundException - if file is not found.getInstance(Reader),
getInstance(File)
public static java.io.Reader getInstance(java.net.URL url,
java.lang.String charset)
By repeatable-read we mean, after close(), the next
invocation of read(char[], int, int) will re-open the reader.
Note: it is efficient since we don't have to buffer the content of the file to make it repeatable-read.
charset - the charset. If null, "UTF-8" is assumed.
java.lang.IllegalArgumentException - if file is null.getInstance(Reader),
getInstance(String, String)public static java.io.Reader getInstance(java.net.URL url)
By repeatable-read we mean, after close(), the next
invocation of read(char[], int, int) will re-open the reader.
Note: it is efficient since we don't have to buffer the content of the file to make it repeatable-read.
java.lang.IllegalArgumentException - if file is null.getInstance(Reader),
getInstance(String)
public int read(char[] cbuf,
int off,
int len)
throws java.io.IOException
read in class java.io.Readerjava.io.IOException
public void close()
throws java.io.IOException
read(char[], int, int)
re-opens the buffered reader.
close in interface java.io.Closeableclose in class java.io.Readerjava.io.IOException
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||