public class Base64Decoder
extends java.io.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);
| Constructor and Description |
|---|
Base64Decoder(java.io.InputStream in)
Constructs a new Base64 decoder that reads input from the given
InputStream.
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
decode(java.lang.String encoded)
Returns the decoded form of the given encoded string, as a String.
|
static byte[] |
decodeToBytes(java.lang.String encoded)
Returns the decoded form of the given encoded string, as bytes.
|
static void |
main(java.lang.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.
|
public Base64Decoder(java.io.InputStream in)
in - the input streampublic int read()
throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOException - if an I/O error occurspublic int read(byte[] buf,
int off,
int len)
throws java.io.IOException
read in class java.io.FilterInputStreambuf - the buffer into which the data is readoff - the start offset of the datalen - the maximum number of bytes to readjava.io.IOException - if an I/O error occurspublic static java.lang.String decode(java.lang.String encoded)
encoded - the string to decodepublic static byte[] decodeToBytes(java.lang.String encoded)
encoded - the string to decodepublic static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception