|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
org.apache.james.mime4j.decoder.Base64OutputStream
public class Base64OutputStream
This class is based on Base64 and Base64OutputStream code from Commons-Codec 1.4 Provides Base64 encoding and decoding as defined by RFC 2045.
This class implements section 6.8. Base64 Content-Transfer-Encoding from RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies by Freed and Borenstein.
Field Summary |
---|
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
Base64OutputStream(java.io.OutputStream os)
Default constructor: lineLength is 76, and the lineSeparator is CRLF when encoding, and all forms can be decoded. |
|
Base64OutputStream(java.io.OutputStream os,
int lineLength)
Consumer can use this constructor to choose a different lineLength when encoding (lineSeparator is still CRLF). |
|
Base64OutputStream(java.io.OutputStream os,
int lineLength,
byte[] lineSeparator)
Consumer can use this constructor to choose a different lineLength and lineSeparator when encoding. |
Method Summary | |
---|---|
void |
close()
Terminates the BASE64 coded content and flushes the internal buffers. |
void |
flush()
Flushes this output stream and forces any buffered output bytes to be written out to the stream. |
static boolean |
isBase64(byte octet)
Returns whether or not the octet is in the base 64 alphabet. |
void |
write(byte[] b,
int offset,
int len)
Writes len bytes from the specified
b array starting at offset to
this output stream. |
void |
write(int i)
Writes the specified byte to this output stream. |
Methods inherited from class java.io.FilterOutputStream |
---|
write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Base64OutputStream(java.io.OutputStream os)
public Base64OutputStream(java.io.OutputStream os, int lineLength)
Consumer can use this constructor to choose a different lineLength when encoding (lineSeparator is still CRLF). All forms of data can be decoded.
Note: lineLengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data.
lineLength
- each line of encoded data will be at most this long
(rounded up to nearest multiple of 4).
If lineLength <= 0, then the output will not be divided into lines (chunks).
Ignored when decoding.public Base64OutputStream(java.io.OutputStream os, int lineLength, byte[] lineSeparator)
Consumer can use this constructor to choose a different lineLength and lineSeparator when encoding. All forms of data can be decoded.
Note: lineLengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data.
lineLength
- Each line of encoded data will be at most this long
(rounded up to nearest multiple of 4). Ignored when decoding.
If <= 0, then output will not be divided into lines (chunks).lineSeparator
- Each line of encoded data will end with this
sequence of bytes.
If lineLength <= 0, then the lineSeparator is not used.
java.lang.IllegalArgumentException
- The provided lineSeparator included
some base64 characters. That's not going to work!Method Detail |
---|
public static boolean isBase64(byte octet)
octet
is in the base 64 alphabet.
octet
- The value to test
true
if the value is defined in the the base 64 alphabet, false
otherwise.public void write(int i) throws java.io.IOException
byte
to this output stream.
write
in class java.io.FilterOutputStream
java.io.IOException
public void write(byte[] b, int offset, int len) throws java.io.IOException
len
bytes from the specified
b
array starting at offset
to
this output stream.
write
in class java.io.FilterOutputStream
b
- source byte arrayoffset
- where to start reading the byteslen
- maximum number of bytes to write
java.io.IOException
- if an I/O error occurs.
java.lang.NullPointerException
- if the byte array parameter is null
java.lang.IndexOutOfBoundsException
- if offset, len or buffer size are invalidpublic void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.FilterOutputStream
java.io.IOException
- if an I/O error occurs.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.FilterOutputStream
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |