|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream java.io.FilterOutputStream com.gridsystems.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);
Field Summary |
---|
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
Base64Encoder(java.io.OutputStream out)
Constructs a new Base64 encoder that writes output to the given OutputStream. |
Method Summary | |
---|---|
static byte[] |
binaryEncode(byte[] unencoded)
Returns the encoded form of the given unencoded byte array. |
static byte[] |
binaryEncode(java.io.InputStream is)
Returns the encoded form of the given unencoded byte array. |
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(java.lang.String s)
Returns the Base64 encoded form of the given string. |
void |
write(byte[] b,
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. |
void |
write(java.lang.String s)
Write a String to the output stream. |
Methods inherited from class java.io.FilterOutputStream |
---|
flush, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Base64Encoder(java.io.OutputStream out)
out
- the output streamMethod Detail |
---|
public void write(int b) throws java.io.IOException
write
in class java.io.FilterOutputStream
b
- the byte to write
java.io.IOException
- if an I/O error occurspublic void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.FilterOutputStream
b
- the data to be writtenoff
- the start offset of the datalen
- the length of the data
java.io.IOException
- if an I/O error occurspublic void write(java.lang.String s) throws java.io.IOException
s
- the string to write
java.io.IOException
- if an I/O error occurspublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.FilterOutputStream
java.io.IOException
- if an I/O error occurspublic static java.lang.String encode(java.lang.String s)
s
- the string to encode
public static byte[] binaryEncode(byte[] unencoded)
unencoded
- the byte array to encode
public static byte[] binaryEncode(java.io.InputStream is)
is
- the input stream to encode
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |