public final class Base64InputStream
extends java.io.FilterInputStream
A Base64InputStream decodes Base64-encoded bytes read from the given InputStream.
This stream is buffered. That means that several bytes have already been read and decoded from the inner input stream. By default the buffer size is: 8192.
Warning ! To fill the buffer of a Base64InputStream with N bytes, (N/3)*4 bytes must be fetched from the inner input stream. Indeed, with the Base64 encoding, the number of encoded bytes is always greater than the number of the corresponding decoded bytes: 3 bytes will be encoded by 4 characters encoded on 6 bits (which allows an alphabet of 2^6=64 characters, hence base64). Consequently: for a buffer of 8192 bytes, 10924 bytes are needed.
However the number of bytes stored in the buffer may be less than the size given at the initialization. That is to say: the buffer can contain AT MOST 8192 decoded bytes. Indeed some bytes coming from the inner input stream may correspond to invalid Base64 characters. In this case, they are ignored and so they are not stored in the buffer.
A Base64InputStream writes a warning in the standard error output when:
A Base64InputStream throws an exception when:
The mark(int) and reset() methods are not supported in a Base64InputStream.
Base64| Constructor | Description |
|---|---|
Base64InputStream(java.io.InputStream encodedStream) |
|
Base64InputStream(java.io.InputStream encodedStream,
int bufferSize) |
| Modifier and Type | Method | Description |
|---|---|---|
int |
available() |
|
void |
close() |
|
void |
mark(int readlimit) |
|
boolean |
markSupported() |
|
int |
read() |
|
int |
read(byte[] b) |
|
int |
read(byte[] b,
int off,
int len) |
|
void |
reset() |
|
long |
skip(long n) |
public Base64InputStream(java.io.InputStream encodedStream)
public Base64InputStream(java.io.InputStream encodedStream,
int bufferSize)
encodedStream - bufferSize - public int available()
throws java.io.IOException
available in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read()
throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read(byte[] b)
throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic long skip(long n)
throws java.io.IOException
skip in class java.io.FilterInputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in class java.io.FilterInputStreamjava.io.IOExceptionpublic boolean markSupported()
markSupported in class java.io.FilterInputStreampublic void mark(int readlimit)
mark in class java.io.FilterInputStreampublic void reset()
throws java.io.IOException
reset in class java.io.FilterInputStreamjava.io.IOException