fedora.server.journal.helpers
Class EncodingBase64InputStream
java.lang.Object
fedora.server.journal.helpers.EncodingBase64InputStream
public class EncodingBase64InputStream
- extends java.lang.Object
Title: EncodingBase64InputStream.java
Description: Wraps an InputStream with a Base64 encoder, so when you
"read" from the stream, you don't get bytes from the InputStream, you get
Strings of Base64-encoded characters.
Base64 encoding is defined in Internet RFC 3548, found at
http://tools.ietf.org/html/rfc3548 (among other places).
- Version:
- $Id: EncodingBase64InputStream.java 5025 2006-09-01 22:08:17 +0000
(Fri, 01 Sep 2006) cwilper $
- Author:
- jblake@cs.cornell.edu
|
Method Summary |
void |
close()
Close the InputStream, and prevent any further reads. |
java.lang.String |
read(int maxStringLength)
Read encoded data from the stream. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
EncodingBase64InputStream
public EncodingBase64InputStream(java.io.InputStream stream)
- Parameters:
stream - the source of data bytes to be encoded.
EncodingBase64InputStream
public EncodingBase64InputStream(java.io.InputStream stream,
int bufferSize)
- Parameters:
stream - the source of data bytes to be encoded.bufferSize - the maximum number of bytes to read at one time.
- Throws:
java.lang.IllegalArgumentException - if bufferSize is not between 10 and 1,000,000.
read
public java.lang.String read(int maxStringLength)
throws java.io.IOException
- Read encoded data from the stream. Data is read in 3-byte multiples and
encoded into 4-character sequences, per the Base64 specification. As many
bytes as possible will be read, limited by the amount of data available
and by the limitation of maxStringLength on the size of the resulting
encoded String. Since the smallest unit of encoded data is 4 characters,
maxStringLength must not be less than 4.
- Parameters:
maxStringLength - the resulting String will be no longer than this.
- Returns:
- a String that is no longer than maxStringLength, or null if no
data remains to be read.
- Throws:
java.lang.IllegalArgumentException - if maxStringLength is less than 4.
java.lang.IllegalStateException - if called after the stream is closed.
java.io.IOException - from inner InputStream.
close
public void close()
throws java.io.IOException
- Close the InputStream, and prevent any further reads.
- Throws:
java.io.IOException - from the inner InputStream