iaik.utils
Class Base64InputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--iaik.utils.Base64InputStream
- Direct Known Subclasses:
- ASN1InputStream
- public class Base64InputStream
- extends FilterInputStream
This class represents a FilterOutputStream that decodes Base64 encoded
data passing through it. For reading - and decoding - Base64 encoded
data from the underlying input stream, use one of the read
methods.
Base64 is the encoding format used by Multipurpose Internet Mail
Extension (Mime) for transmitting non-text material over text-only
communications channels. Base64 is based on a 65-character subset of
US-ASCII, enabling 6 bits to be represented per printable character
(see RFC 1521).
This class may be used for decoding Base64 encoding data read in from some
file, e.g.:
FileInputStream fis = new FileInputStream("test/base64.enc");
Base64InputStream base64is = new Base64InputStream(fis);
byte[] data = new byte[1000];
int r;
while ((r = base64is.read(data)) != -1) {
System.out.print(new String(data));
}
- Version:
- File Revision 18
- See Also:
Base64OutputStream
Constructor Summary |
Base64InputStream(InputStream in)
Creates a new Base64InputStream to read data from the specified input stream. |
Base64InputStream(InputStream in,
boolean ignoreInvalidCharacters)
Creates a new Base64InputStream to read data from the specified input stream
and specifies whether or not to ignore invalid BASE-64 characters. |
Method Summary |
protected void |
notify(byte[] buffer)
This method is called if a character specified with
NOTIFY is encountered.
|
int |
read()
Returns the next BASE64 decoded byte, read from the underlying input stream. |
int |
read(byte[] b,
int off,
int len)
Reads and decodes the specified number of data bytes from the underlying input
stream into a byte array until bytes are available.
|
void |
setIgnoreInvalidCharacters(boolean ignoreInvalidCharacters)
Sets whether or not to ignore invalid BASE-64 characters in the input.
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
decoding
protected int[] decoding
ERROR
protected static final int ERROR
IGNORE
protected static final int IGNORE
NOTIFY
protected static final int NOTIFY
Base64InputStream
public Base64InputStream(InputStream in)
- Creates a new Base64InputStream to read data from the specified input stream.
- Parameters:
in
- the underlying input stream.
Base64InputStream
public Base64InputStream(InputStream in,
boolean ignoreInvalidCharacters)
- Creates a new Base64InputStream to read data from the specified input stream
and specifies whether or not to ignore invalid BASE-64 characters.
- Parameters:
in
- the underlying input stream.
setIgnoreInvalidCharacters
public void setIgnoreInvalidCharacters(boolean ignoreInvalidCharacters)
- Sets whether or not to ignore invalid BASE-64 characters in the input.
If set to false (the default) a Base64Exception will be thrown when
such characters are encountered, otherwise they are just ignored.
read
public int read(byte[] b,
int off,
int len)
throws IOException,
Base64Exception
- Reads and decodes the specified number of data bytes from the underlying input
stream into a byte array until bytes are available.
The bytes are decoded and read to the given byte array, beginning at position
off
. The number of bytes read to the array are returned.
- Overrides:
read
in class FilterInputStream
- Parameters:
b
- the byte array into which the decoded bytes are readoff
- the offset indicating the position in b
to which the
first decoded byte shall be readlen
- the maximum number of bytes to be read- Returns:
- the number of bytes read into the byte array, or -1 if no more
bytes are available because the end of the stream already has
been reached
- Throws:
IOException
- if an I/O error occurs.Base64Exception
- if there is an Base64 format error
notify
protected void notify(byte[] buffer)
throws IOException
- This method is called if a character specified with
NOTIFY
is encountered.
This method does nothing and shall be overwritten by a sub-class.
- Parameters:
buffer
- the characters already read from the input stream; and the
first one was marked with NOTIFY- Throws:
IOException
- allows the subclass to throw an Exception if an error occurs
read
public int read()
throws IOException,
Base64Exception
- Returns the next BASE64 decoded byte, read from the underlying input stream.
- Overrides:
read
in class FilterInputStream
- Returns:
- the next decoded byte, or -1 if no more
byte is available because the end of the stream already has
been reached
- Throws:
IOException
- if an I/O error occursBase64Exception
- if there is a Base64 format error
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).
|
PREV CLASS
NEXT CLASS |
FRAMES
NO FRAMES |
SUMMARY: INNER | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD |
IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK