Package org.apache.james.mime4j.codec
Class Base64OutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.james.mime4j.codec.Base64OutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class Base64OutputStream extends java.io.OutputStream
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.Code is based on Base64 and Base64OutputStream code from Commons-Codec 1.4.
- See Also:
- RFC 2045
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Base64OutputStream.ExtraCrlfOutputStream
-
Field Summary
Fields Modifier and Type Field Description (package private) static byte[]
BASE64_TABLE
private static byte[]
CRLF_SEPARATOR
private static int
DEFAULT_LINE_LENGTH
private java.io.OutputStream
delegate
-
Constructor Summary
Constructors Constructor Description Base64OutputStream(java.io.OutputStream out)
Creates aBase64OutputStream
that writes the encoded data to the given output stream using the default line length (76) and line separator (CRLF).Base64OutputStream(java.io.OutputStream out, int lineLength)
Creates aBase64OutputStream
that writes the encoded data to the given output stream using the given line length and the default line separator (CRLF).Base64OutputStream(java.io.OutputStream out, int lineLength, byte[] lineSeparator)
Creates aBase64OutputStream
that writes the encoded data to the given output stream using the given line length and line separator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int i)
-
-
-
Field Detail
-
DEFAULT_LINE_LENGTH
private static final int DEFAULT_LINE_LENGTH
- See Also:
- Constant Field Values
-
CRLF_SEPARATOR
private static final byte[] CRLF_SEPARATOR
-
BASE64_TABLE
static final byte[] BASE64_TABLE
-
delegate
private final java.io.OutputStream delegate
-
-
Constructor Detail
-
Base64OutputStream
public Base64OutputStream(java.io.OutputStream out)
Creates aBase64OutputStream
that writes the encoded data to the given output stream using the default line length (76) and line separator (CRLF).- Parameters:
out
- underlying output stream.
-
Base64OutputStream
public Base64OutputStream(java.io.OutputStream out, int lineLength)
Creates aBase64OutputStream
that writes the encoded data to the given output stream using the given line length and the default line separator (CRLF).The given line length will be rounded up to the nearest multiple of 4. If the line length is zero then the output will not be split into lines.
- Parameters:
out
- underlying output stream.lineLength
- desired line length.
-
Base64OutputStream
public Base64OutputStream(java.io.OutputStream out, int lineLength, byte[] lineSeparator)
Creates aBase64OutputStream
that writes the encoded data to the given output stream using the given line length and line separator.The given line length will be rounded up to the nearest multiple of 4. If the line length is zero then the output will not be split into lines and the line separator is ignored.
The line separator must not include characters from the BASE64 alphabet (including the padding character
=
).- Parameters:
out
- underlying output stream.lineLength
- desired line length.lineSeparator
- line separator to use.
-
-
Method Detail
-
write
public void write(int i) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
-