com.jkristian.io
Class Base64EncodeOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.jkristian.io.Base64EncodeOutputStream
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable
public class Base64EncodeOutputStream
- extends java.io.FilterOutputStream
A filter that encodes output from binary bytes to base64 encoding.
This filter doesn't break the encoded data into lines (as required
for MIME); use another filter to do that, if needed.
Base64 encoding is defined by RFC 2045 (MIME) section 6.8.
Field Summary |
protected static byte[] |
map
Maps from a sextet to its encoding. |
protected static byte |
PAD
This byte is appended to encoded data, as needed to
make the encoding an integral multiple of four bytes long. |
Fields inherited from class java.io.FilterOutputStream |
out |
Method Summary |
void |
flush()
|
static void |
main(java.lang.String[] args)
A unit test. |
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
Methods inherited from class java.io.FilterOutputStream |
close, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PAD
protected static final byte PAD
- This byte is appended to encoded data, as needed to
make the encoding an integral multiple of four bytes long.
- See Also:
- Constant Field Values
map
protected static final byte[] map
- Maps from a sextet to its encoding.
Base64EncodeOutputStream
public Base64EncodeOutputStream(java.io.OutputStream out)
- Parameters:
out
- should be buffered (e.g. a BufferedOutputStream) for
best performance. This class will write to it four bytes at a time.
write
public void write(int b)
throws java.io.IOException
- Overrides:
write
in class java.io.FilterOutputStream
- Throws:
java.io.IOException
write
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
- Overrides:
write
in class java.io.FilterOutputStream
- Throws:
java.io.IOException
flush
public void flush()
throws java.io.IOException
- Specified by:
flush
in interface java.io.Flushable
- Overrides:
flush
in class java.io.FilterOutputStream
- Throws:
java.io.IOException
main
public static void main(java.lang.String[] args)
throws java.io.IOException
- A unit test.
- Throws:
java.io.IOException