All Packages Class Hierarchy This Package Previous Next Index
Class com.oreilly.servlet.Base64Encoder
java.lang.Object
|
+----java.io.OutputStream
|
+----java.io.FilterOutputStream
|
+----com.oreilly.servlet.Base64Encoder
- public class Base64Encoder
- extends FilterOutputStream
A class to encode Base64 streams and strings.
See RFC 1521 section 5.2 for details of the Base64 algorithm.
This class can be used for encoding strings:
String unencoded = "webmaster:try2gueSS";
String encoded = Base64Encoder.encode(unencoded);
or for encoding streams:
OutputStream out = new Base64Encoder(System.out);
- Version:
- 1.1, 2000/11/17, fixed bug with sign bit for char values
- Author:
- Jason Hunter, Copyright © 2000
-
Base64Encoder(OutputStream)
- Constructs a new Base64 encoder that writes output to the given
OutputStream.
-
close()
- Closes the stream, this MUST be called to ensure proper padding is
written to the end of the output stream.
-
encode(String)
- Returns the encoded form of the given unencoded string.
-
main(String[])
-
-
write(byte[], int, int)
- Writes the given byte array to the output stream in an
encoded form.
-
write(int)
- Writes the given byte to the output stream in an encoded form.
Base64Encoder
public Base64Encoder(OutputStream out)
- Constructs a new Base64 encoder that writes output to the given
OutputStream.
- Parameters:
- out - the output stream
write
public void write(int b) throws IOException
- Writes the given byte to the output stream in an encoded form.
- Throws: IOException
- if an I/O error occurs
- Overrides:
- write in class FilterOutputStream
write
public void write(byte b[],
int off,
int len) throws IOException
- Writes the given byte array to the output stream in an
encoded form.
- Parameters:
- b - the data to be written
- off - the start offset of the data
- len - the length of the data
- Throws: IOException
- if an I/O error occurs
- Overrides:
- write in class FilterOutputStream
close
public void close() throws IOException
- Closes the stream, this MUST be called to ensure proper padding is
written to the end of the output stream.
- Throws: IOException
- if an I/O error occurs
- Overrides:
- close in class FilterOutputStream
encode
public static String encode(String unencoded)
- Returns the encoded form of the given unencoded string.
- Parameters:
- unencoded - the string to encode
- Returns:
- the encoded form of the unencoded string
main
public static void main(String args[]) throws Exception
All Packages Class Hierarchy This Package Previous Next Index