| java.lang.Object java.io.InputStream java.io.FilterInputStream com.knowgate.misc.Base64Decoder
Base64Decoder | public class Base64Decoder extends FilterInputStream (Code) | | 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:
String encoded = "d2VibWFzdGVyOnRyeTJndWVTUw";
String decoded = Base64Decoder.decode(encoded);
or for decoding streams:
InputStream in = new Base64Decoder(System.in);
author: Jason Hunter, Copyright © 2000 version: 1.1, 2002/11/01, added decodeToBytes() to better handle binary version: data (thanks to Sean Graham) version: 1.0, 2000/06/11 |
Constructor Summary | |
public | Base64Decoder(InputStream in) Constructs a new Base64 decoder that reads input from the given
InputStream. |
Method Summary | |
public static String | decode(String encoded) Returns the decoded form of the given encoded string, as a String.
Note that not all binary data can be represented as a String, so this
method should only be used for encoded String data. | public static byte[] | decodeToBytes(String encoded) Returns the decoded form of the given encoded string, as bytes. | public static void | main(String[] args) | public int | read() Returns the next decoded character from the stream, or -1 if
end of stream was reached. | public 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. |
Base64Decoder | public Base64Decoder(InputStream in)(Code) | | Constructs a new Base64 decoder that reads input from the given
InputStream.
Parameters: in - the input stream |
decode | public static String decode(String encoded)(Code) | | Returns the decoded form of the given encoded string, as a String.
Note that not all binary data can be represented as a String, so this
method should only be used for encoded String data. Use decodeToBytes()
otherwise.
Parameters: encoded - the string to decode the decoded form of the encoded string |
decodeToBytes | public static byte[] decodeToBytes(String encoded)(Code) | | Returns the decoded form of the given encoded string, as bytes.
Parameters: encoded - the string to decode the decoded form of the encoded string |
read | public int read() throws IOException(Code) | | Returns the next decoded character from the stream, or -1 if
end of stream was reached.
the decoded character, or -1 if the end of theinput stream is reached exception: IOException - if an I/O error occurs |
read | public int read(byte[] buf, int off, int len) throws IOException(Code) | | Reads decoded data into an array of bytes and returns the actual
number of bytes read, or -1 if end of stream was reached.
Parameters: buf - the buffer into which the data is read Parameters: off - the start offset of the data Parameters: len - the maximum number of bytes to read the actual number of bytes read, or -1 if the end of theinput stream is reached exception: IOException - if an I/O error occurs |
|
|