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);
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, skippublic Base64Decoder(InputStream in)
in - the input streampublic int read()
throws IOException
read in class FilterInputStreamIOException - if an I/O error occurspublic int read(byte[] buf,
int off,
int len)
throws IOException
read in class FilterInputStreambuf - 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 decodeCopyright © 2017. All rights reserved.