Package com.tangosol.io
Class Base64OutputStream
java.lang.Object
java.io.OutputStream
com.tangosol.io.Base64OutputStream
- All Implemented Interfaces:
 com.oracle.coherence.common.io.OutputStreaming,OutputStreaming,Closeable,Flushable,AutoCloseable
Writes binary data into a Writer using IETF RFC 2045 Base64 Content
 Transfer Encoding.
 If the Base64OutputStream is not the first to write data into the
 Writer, it may be desired to write a line feed before Base64 data.
 According to the specification, Base64 data cannot exceed 76
 characters per line.
 Be careful to avoid calling flush() except when a stream of Base64
 content is complete.
- Author:
 - cp 2000.09.06
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final char[]Base64 encodes into this "alphabet" of 64 characters.protected static final charThe Base64 line feed character.protected static final charThe Base64 padding character.protected static final intThe number of Base64 character groups in one line.protected byte[]Accumulated bytes.protected char[]An array that is used to send 4 characters at a time to the underlying Writer object.protected intThe number of bytes accumulated (0, 1, 2 or 3).protected intThe number of groups left to write in the current line.protected booleanTrue if lines are to be broken by BASE64_LF;protected booleanTrue after close is invoked.protected WriterThe Writer object to which the Base64 encoded data is written. - 
Constructor Summary
ConstructorsConstructorDescriptionBase64OutputStream(Writer writer) Construct a Base64OutputStream on a Writer object.Base64OutputStream(Writer writer, boolean fBreakLines) Construct a Base64OutputStream on a Writer object and specifying a line-break option. - 
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the stream, flushing any accumulated bytes.static char[]encode(byte[] ab) Encode the passed binary data using Base64 encoding.static char[]encode(byte[] ab, boolean fBreakLines) Encode the passed binary data using Base64 encoding.static char[]encode(byte[] ab, int ofb, int cb, boolean fBreakLines) Encode the passed binary data using Base64 encoding.voidflush()Close the stream, flushing any accumulated bytes.protected voidFlushes the bytes accumulated by the write(int) method.voidwrite(byte[] ab, int ofb, int cb) Writeslenbytes from the specified byte array starting at offsetoffto this output stream.voidwrite(int b) Writes the specified byte to this output stream.Methods inherited from class java.io.OutputStream
nullOutputStream, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.oracle.coherence.common.io.OutputStreaming
write 
- 
Field Details
- 
BASE64_ALPHABET
protected static final char[] BASE64_ALPHABETBase64 encodes into this "alphabet" of 64 characters. - 
BASE64_PAD
protected static final char BASE64_PADThe Base64 padding character. Base64 is encoded into 4-character chunks; if the last chunk does not contain 4 characters, it is filled with this padding character.- See Also:
 
 - 
BASE64_LF
protected static final char BASE64_LFThe Base64 line feed character. Base64 is encoded into 76-character lines unless .- See Also:
 
 - 
GROUPS_PER_LINE
protected static final int GROUPS_PER_LINEThe number of Base64 character groups in one line. This number prevents a line from exceeding 76 characters.- See Also:
 
 - 
m_fClosed
protected boolean m_fClosedTrue after close is invoked. - 
m_writer
The Writer object to which the Base64 encoded data is written. - 
m_fBreakLines
protected boolean m_fBreakLinesTrue if lines are to be broken by BASE64_LF; - 
m_cLineGroups
protected int m_cLineGroupsThe number of groups left to write in the current line. - 
m_abAccum
protected byte[] m_abAccumAccumulated bytes. - 
m_cAccum
protected int m_cAccumThe number of bytes accumulated (0, 1, 2 or 3). - 
m_achGroup
protected char[] m_achGroupAn array that is used to send 4 characters at a time to the underlying Writer object. 
 - 
 - 
Constructor Details
- 
Base64OutputStream
Construct a Base64OutputStream on a Writer object.- Parameters:
 writer- the Writer to write the Base64 encoded data to
 - 
Base64OutputStream
Construct a Base64OutputStream on a Writer object and specifying a line-break option.- Parameters:
 writer- the Writer to write the Base64 encoded data tofBreakLines- true to break the output into 76-character lines
 
 - 
 - 
Method Details
- 
write
Writes the specified byte to this output stream.- Specified by:
 writein interfacecom.oracle.coherence.common.io.OutputStreaming- Specified by:
 writein classOutputStream- Parameters:
 b- thebyte.- Throws:
 IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if the output stream has been closed.
 - 
write
Writeslenbytes from the specified byte array starting at offsetoffto this output stream.If
bisnull, aNullPointerExceptionis thrown.If
offis negative, orlenis negative, oroff+lenis greater than the length of the arrayb, then an IndexOutOfBoundsException is thrown.- Specified by:
 writein interfacecom.oracle.coherence.common.io.OutputStreaming- Overrides:
 writein classOutputStream- Parameters:
 ab- the dataofb- the start offset in the datacb- the number of bytes to write- Throws:
 IOException- if an I/O error occurs. In particular, anIOExceptionis thrown if the output stream is closed.
 - 
flush
Close the stream, flushing any accumulated bytes. The underlying writer is not closed.- Specified by:
 flushin interfaceFlushable- Specified by:
 flushin interfacecom.oracle.coherence.common.io.OutputStreaming- Overrides:
 flushin classOutputStream- Throws:
 IOException- if an I/O error occurs
 - 
close
Close the stream, flushing any accumulated bytes. The underlying writer is not closed.- Specified by:
 closein interfaceAutoCloseable- Specified by:
 closein interfaceCloseable- Specified by:
 closein interfacecom.oracle.coherence.common.io.OutputStreaming- Overrides:
 closein classOutputStream- Throws:
 IOException- if an I/O error occurs
 - 
flushAccumulator
Flushes the bytes accumulated by the write(int) method.- Throws:
 IOException- if an I/O error occurs
 - 
encode
public static char[] encode(byte[] ab) Encode the passed binary data using Base64 encoding.- Parameters:
 ab- the array containing the bytes to encode- Returns:
 - the encoded data as a char array
 
 - 
encode
public static char[] encode(byte[] ab, boolean fBreakLines) Encode the passed binary data using Base64 encoding.- Parameters:
 ab- the array containing the bytes to encodefBreakLines- true to break the output into 76-character lines- Returns:
 - the encoded data as a char array
 
 - 
encode
public static char[] encode(byte[] ab, int ofb, int cb, boolean fBreakLines) Encode the passed binary data using Base64 encoding.- Parameters:
 ab- the array containing the bytes to encodeofb- the start offset in the byte arraycb- the number of bytes to encodefBreakLines- true to break the output into 76-character lines- Returns:
 - the encoded data as a char array
 
 
 -