public class Base64Decoder extends FilterInputStream
This class can be used for decoding strings:
or for decoding streams:String encoded = "d2VibWFzdGVyOnRyeTJndWVTUw"; String decoded = Base64Decoder.decode(encoded);
InputStream in = new Base64Decoder(System.in);
Modifier and Type | Field and Description |
---|---|
private int |
carryOver |
private int |
charCount |
private static char[] |
chars |
private static int[] |
ints |
in
Constructor and Description |
---|
Base64Decoder(InputStream in)
Constructs a new Base64 decoder that reads input from the given
InputStream.
|
Modifier and Type | Method and Description |
---|---|
static String |
decode(String encoded)
Returns the decoded form of the given encoded string, as a String.
|
static byte[] |
decodeToBytes(String encoded)
Returns the decoded form of the given encoded string, as bytes.
|
static void |
main(String[] args) |
int |
read()
Returns the next decoded character from the stream, or -1 if
end of stream was reached.
|
int |
read(byte[] buf,
int off,
int len)
Reads decoded data into an array of bytes and returns the actual
number of bytes read, or -1 if end of stream was reached.
|
available, close, mark, markSupported, read, reset, skip
private static final char[] chars
private static final int[] ints
private int charCount
private int carryOver
public Base64Decoder(InputStream in)
in
- the input streampublic int read() throws IOException
read
in class FilterInputStream
IOException
- if an I/O error occurspublic int read(byte[] buf, int off, int len) throws IOException
read
in class FilterInputStream
buf
- the buffer into which the data is readoff
- the start offset of the datalen
- the maximum number of bytes to readIOException
- if an I/O error occurspublic static String decode(String encoded)
encoded
- the string to decodepublic static byte[] decodeToBytes(String encoded)
encoded
- the string to decodeWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses