All Packages Class Hierarchy This Package Previous Next Index
Class com.oreilly.servlet.Base64Decoder
java.lang.Object
|
+----java.io.InputStream
|
+----java.io.FilterInputStream
|
+----com.oreilly.servlet.Base64Decoder
- public class Base64Decoder
- extends FilterInputStream
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);
- Version:
- 1.0, 2000/06/11
- Author:
- Jason Hunter, Copyright © 2000
-
Base64Decoder(InputStream)
- Constructs a new Base64 decoder that reads input from the given
InputStream.
-
decode(String)
- Returns the decoded form of the given encoded string.
-
main(String[])
-
-
read()
- Returns the next decoded character from the stream, or -1 if
end of stream was reached.
-
read(byte[], int, int)
- 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)
- Constructs a new Base64 decoder that reads input from the given
InputStream.
- Parameters:
- in - the input stream
read
public int read() throws IOException
- Returns the next decoded character from the stream, or -1 if
end of stream was reached.
- Returns:
- the decoded character, or -1 if the end of the
input stream is reached
- Throws: IOException
- if an I/O error occurs
- Overrides:
- read in class FilterInputStream
read
public int read(byte b[],
int off,
int len) throws IOException
- 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
- off - the start offset of the data
- len - the maximum number of bytes to read
- Returns:
- the actual number of bytes read, or -1 if the end of the
input stream is reached
- Throws: IOException
- if an I/O error occurs
- Overrides:
- read in class FilterInputStream
decode
public static String decode(String encoded)
- Returns the decoded form of the given encoded string.
- Parameters:
- encoded - the string to decode
- Returns:
- the decoded form of the encoded string
main
public static void main(String args[]) throws Exception
All Packages Class Hierarchy This Package Previous Next Index