|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
com.oreilly.servlet.Base64Encoder
public class Base64Encoder
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:
or for encoding streams:String unencoded = "webmaster:try2gueSS"; String encoded = Base64Encoder.encode(unencoded);
OutputStream out = new Base64Encoder(System.out);
| Constructor Summary | |
|---|---|
Base64Encoder(java.io.OutputStream out)
Constructs a new Base64 encoder that writes output to the given OutputStream. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the stream, this MUST be called to ensure proper padding is written to the end of the output stream. |
static java.lang.String |
encode(byte[] bytes)
Returns the encoded form of the given unencoded string. |
static java.lang.String |
encode(java.lang.String unencoded)
Returns the encoded form of the given unencoded string. |
static void |
main(java.lang.String[] args)
|
void |
write(byte[] buf,
int off,
int len)
Writes the given byte array to the output stream in an encoded form. |
void |
write(int b)
Writes the given byte to the output stream in an encoded form. |
| Methods inherited from class java.io.FilterOutputStream |
|---|
flush, write |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Base64Encoder(java.io.OutputStream out)
out - the output stream| Method Detail |
|---|
public void write(int b)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOException - if an I/O error occurs
public void write(byte[] buf,
int off,
int len)
throws java.io.IOException
write in class java.io.FilterOutputStreamb - the data to be writtenoff - the start offset of the datalen - the length of the data
java.io.IOException - if an I/O error occurs
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.FilterOutputStreamjava.io.IOException - if an I/O error occurspublic static java.lang.String encode(java.lang.String unencoded)
unencoded - the string to encode
public static java.lang.String encode(byte[] bytes)
unencoded - the string to encode
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 | |||||||||