uk.org.ogsadai.common
Class Base64InputStream
java.lang.Object
|
+--uk.org.ogsadai.common.Base64InputStream
- public class Base64InputStream
- extends java.lang.Object
A class that supports Base64 encoding of data from a java.io.InputStream
.
- Author:
- The OGSA-DAI Project Team
Constructor Summary |
Base64InputStream(java.io.InputStream in)
Create a new Base64InputStream . |
Method Summary |
int |
available()
Reads the available data from the InputStream and encodes it. |
void |
close()
Close the InputStream and the Base64InputStream . |
int |
read(byte[] b)
Read from the InputStream , Base64 encode the data and insert it into the byte array. |
private void |
readAndEncode()
Read from the InputStream , Base64 encode the data and store it locally. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
COPYRIGHT_NOTICE
private static final java.lang.String COPYRIGHT_NOTICE
-
- See Also:
- Constant Field Values
LOG
private static DAILogger LOG
-
BASE64_BUFFER_SIZE
private static final int BASE64_BUFFER_SIZE
-
- See Also:
- Constant Field Values
mInputStream
private java.io.InputStream mInputStream
-
mBuffer
private byte[] mBuffer
-
mEncoded
private byte[] mEncoded
-
mStreamIndex
private int mStreamIndex
-
mStreamHasData
private boolean mStreamHasData
-
Base64InputStream
public Base64InputStream(java.io.InputStream in)
throws OutOfMemoryException
-
Create a new
Base64InputStream
.
Default capacity is 4096 * 3 bytes.
- Parameters:
in
- InputStream
that is to be Base64 encoded.
- Throws:
OutOfMemoryException
- is there is no memory available to create a buffer for the Base64 encoded data.
available
public int available()
throws java.io.IOException,
OutOfMemoryException
-
Reads the available data from the
InputStream
and encodes it.
-
- Returns:
- number of bytes just encoded.
- Throws:
java.io.IOException
- if there is a problem in reading from the InputStream
.
OutOfMemoryException
- is there is no memory available.
- See Also:
InputStream.available()
read
public int read(byte[] b)
throws java.io.IOException,
OutOfMemoryException
-
Read from the
InputStream
, Base64 encode the data and insert it into the byte array.
-
- Parameters:
b
- Byte array into which encoded data is to be inserted..
- Returns:
- number of bytes encoded.
- Throws:
java.io.IOException
- if there is a problem in reading from the InputStream
.
OutOfMemoryException
- is there is no memory available.
- See Also:
InputStream.read(byte[])
readAndEncode
private void readAndEncode()
throws java.io.IOException,
OutOfMemoryException
-
Read from the
InputStream
, Base64 encode the data and store it locally.
-
- Throws:
java.io.IOException
- if there is a problem in reading from the InputStream
.
OutOfMemoryException
- is there is no memory available.
close
public void close()
throws java.io.IOException
-
Close the
InputStream
and the Base64InputStream
.
-
- Throws:
java.io.IOException
- if there is a problem in closing the InputStream
.
- See Also:
InputStream.close()