uk.org.ogsadai.common
Class Base64Reader
java.lang.Object
|
+--java.io.Reader
|
+--uk.org.ogsadai.common.Base64Reader
- public class Base64Reader
- extends java.io.Reader
A Reader that wraps an InputStream and base-64
encodes its contents.
- Author:
- The OGSA-DAI Project Team
| Fields inherited from class java.io.Reader |
lock |
|
Constructor Summary |
Base64Reader(java.io.InputStream input)
Constructs a Base64Reader that wraps the specified
InputStream. |
|
Method Summary |
void |
close()
|
int |
read(char[] cbuf,
int off,
int len)
Read base-64 encoded characters into a portion of an array. |
java.lang.String |
readAll()
Reads and base-64 encodes the entire contents of the wrapped input
stream. |
| Methods inherited from class java.io.Reader |
mark, markSupported, read, read, ready, reset, skip |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Base64Reader
public Base64Reader(java.io.InputStream input)
throws CommonSystemException,
java.lang.IllegalArgumentException
- Constructs a
Base64Reader that wraps the specified
InputStream. Data read from the input stream will be
base-64 encoded.
- Parameters:
input - the InputStream to wrap and encode.
- Throws:
java.lang.IllegalArgumentException - if the input parameter is null
CommonSystemException - if there is not enough memory available to perform the
base-64 encoding.
read
public int read(char[] cbuf,
int off,
int len)
throws java.io.IOException,
java.lang.IndexOutOfBoundsException,
java.lang.IllegalArgumentException
- Read base-64 encoded characters into a portion of an array. This method
will block until some input is available, an I/O error occurs, or the end
of the stream is reached.
- Specified by:
read in class java.io.Reader
- Parameters:
cbuf - Destination bufferoff - Offset at which to start storing characterslen - Maximum number of characters to read
- Returns:
- The number of characters read, or -1 if the end of the stream has
been reached
- Throws:
java.io.IOException - If the reader has already been closed.
java.lang.IndexOutOfBoundsException - If the off or len parameters
contain unsuitable values.
java.lang.IllegalArgumentException - If the cbuf parameter is null
close
public void close()
- Specified by:
close in class java.io.Reader
readAll
public java.lang.String readAll()
throws java.io.IOException,
CommonSystemException
- Reads and base-64 encodes the entire contents of the wrapped input
stream. Note that this method may carry a significant memory overhead
because all the input data will be encoded and stored in memory in its
entirety.
- Returns:
- a
String containing the base-64 encoded data
- Throws:
java.io.IOException - If the reader has already been closed.
CommonSystemException - if there is not enough memory available to perform the
base-64 encoding.