Class Base64InputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.simpleframework.common.encode.Base64InputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class Base64InputStream extends java.io.InputStreamTheBase64InputStreamis 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:
Base64Encoder
-
-
Field Summary
Fields Modifier and Type Field Description private intcountThis is the total number of bytes that have been read.private byte[]decodedThis is used to accumulate the decoded text as an array.private char[]encodedThis is that original base64 text that is to be decoded.private byte[]tempThis is a temporary buffer used to read one byte at a time.
-
Constructor Summary
Constructors Constructor Description Base64InputStream(java.lang.String source)Constructor for theBase64InputStreamobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intread()This is used to read the next byte decoded from the text.intread(byte[] array, int offset, int length)This is used to read the next byte decoded from the text.java.lang.StringtoString()This returns the original base64 text that was encoded.
-
-
-
Field Detail
-
encoded
private char[] encoded
This is that original base64 text that is to be decoded.
-
decoded
private byte[] decoded
This is used to accumulate the decoded text as an array.
-
temp
private byte[] temp
This is a temporary buffer used to read one byte at a time.
-
count
private int count
This is the total number of bytes that have been read.
-
-
Method Detail
-
read
public int read() throws java.io.IOExceptionThis 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:
readin classjava.io.InputStream- Returns:
- this returns the next octet decoded
- Throws:
java.io.IOException
-
read
public int read(byte[] array, int offset, int length) throws java.io.IOExceptionThis 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:
readin classjava.io.InputStream- 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:
java.io.IOException
-
toString
public java.lang.String toString()
This returns the original base64 text that was encoded. This is useful for debugging purposes to see the source data.- Overrides:
toStringin classjava.lang.Object- Returns:
- this returns the original base64 text to decode
-
-