|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
com.oreilly.servlet.Base64Decoder
public class Base64Decoder
A class to decode Base64 streams and strings. See RFC 1521 section 5.2 for details of the Base64 algorithm.
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 Summary | |
|---|---|
Base64Decoder(java.io.InputStream in)
Constructs a new Base64 decoder that reads input from the given InputStream. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.io.FilterInputStream |
|---|
available, close, mark, markSupported, read, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Base64Decoder(java.io.InputStream in)
in - the input stream| Method Detail |
|---|
public int read()
throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOException - if an I/O error occurs
public 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 read
java.io.IOException - if an I/O error occurspublic static java.lang.String decode(java.lang.String encoded)
encoded - the string to decode
public static byte[] decodeToBytes(java.lang.String encoded)
encoded - the string to decode
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||