Class Base64InputStream
java.lang.Object
java.io.InputStream
org.simpleframework.common.encode.Base64InputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
The
Base64InputStream
is used to read base64 text in
the form of a string through a conventional input stream. This is
provided for convenience so that it is possible to encode and
decode binary data as base64 for implementations that would
normally use a binary format.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
This is the total number of bytes that have been read.private byte[]
This is used to accumulate the decoded text as an array.private char[]
This is that original base64 text that is to be decoded.private byte[]
This is a temporary buffer used to read one byte at a time. -
Constructor Summary
ConstructorsConstructorDescriptionBase64InputStream
(String source) Constructor for theBase64InputStream
object. -
Method Summary
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
encoded
private char[] encodedThis is that original base64 text that is to be decoded. -
decoded
private byte[] decodedThis is used to accumulate the decoded text as an array. -
temp
private byte[] tempThis is a temporary buffer used to read one byte at a time. -
count
private int countThis is the total number of bytes that have been read.
-
-
Constructor Details
-
Base64InputStream
Constructor for theBase64InputStream
object. This takes an encoded string and reads it as binary data.- Parameters:
source
- this string containing the encoded data
-
-
Method Details
-
read
This is used to read the next byte decoded from the text. If the data has been fully consumed then this will return the standard -1.- Specified by:
read
in classInputStream
- Returns:
- this returns the next octet decoded
- Throws:
IOException
-
read
This is used to read the next byte decoded from the text. If the data has been fully consumed then this will return the standard -1.- Overrides:
read
in classInputStream
- Parameters:
array
- this is the array to decode the text tooffset
- this is the offset to decode in to the arraythis
- is the number of bytes available to decode to- Returns:
- this returns the number of octets decoded
- Throws:
IOException
-
toString
This returns the original base64 text that was encoded. This is useful for debugging purposes to see the source data.
-