|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
net.rim.device.api.io.Base64OutputStream
public class Base64OutputStream
Output stream for writing Base64 encoded data.
This class implements a stream for writing and encoding data using the Base64 encoding scheme (for a description of which, see RFC 2045).
Sample code
Constructor Summary | ||
---|---|---|
Base64OutputStream(OutputStream outputStream)
Constructs a new Base64OutputSream instance with underlying output stream. |
||
Base64OutputStream(OutputStream outputStream,
boolean insertCR,
boolean insertLF)
Constructs a new Base64OutputStream instance with specific newline and carriage return settings. |
||
Base64OutputStream(OutputStream outputStream,
boolean insertCR,
boolean insertLF,
int newlineTrigger)
Constructs a new Base64OutputStream instance with specific newline and carriage return settings. |
Method Summary | ||
---|---|---|
void |
close()
Closes this output stream. |
|
static byte[] |
encode(byte[] input,
int inputOffset,
int inputLength,
boolean insertCR,
boolean insertLF)
Encodes the provided input into Base 64 and returns the encoded result. |
|
static String |
encodeAsString(byte[] input,
int inputOffset,
int inputLength,
boolean insertCR,
boolean insertLF)
Encodes the provided input into Base 64 and returns the encoded result. |
|
void |
flush()
Flushes this stream, writing out any remaining buffered data. |
|
void |
write(byte[] data)
Writes encoded byte array of data to this stream. |
|
void |
write(byte[] data,
int dataOffset,
int dataLength)
Writes some encoded bytes from byte array to this stream. |
|
void |
write(int data)
Writes encoded byte to this stream. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Base64OutputStream(OutputStream outputStream)
This builds a Base64 output stream that, by default, inserts no newlines or carriage returns. As a result, the output might not be compatible with some mail transports.
outputStream
- Underlying output stream to contain the data.public Base64OutputStream(OutputStream outputStream, boolean insertCR, boolean insertLF)
This builds a Base64 output stream that can, by default, insert newlines and/or carriage returns. If activated, this stream inserts line end characters (either none, CR, LF, or CR/LF) after every 76 encoded characters.
outputStream
- Underlying output stream to contain the data.insertCR
- If true, insert carriage returns (0x0D) after every 76
encoded characters.insertLF
- If true, insert line feeds (0x0A) after every 76 encoded
characters (and after the carriage return if the insertCR parameter is
also true).public Base64OutputStream(OutputStream outputStream, boolean insertCR, boolean insertLF, int newlineTrigger)
This builds a Base64 output stream that can, by default, insert newlines and/or carriage returns. If activated, this stream inserts line end characters (either none, CR, LF, or CR/LF) after every _linefeedTrigger*4 encoded characters.
outputStream
- Underlying output stream to contain the data.insertCR
- If true, insert carriage returns (0x0D) after every _linefeedTrigger*4
encoded characters.insertLF
- If true, insert line feeds (0x0A) after every _linefeedTrigger*4 encoded
characters (and after the carriage return if the insertCR parameter is
also true).linefeedTrigger
- Four times linefeedTrigger is the number of encoded characters
before the specified newline and/or carriage return.Method Detail |
---|
public void write(int data) throws IOException
Invoke this method to encode, and then write, a single byte to this stream.
write
in class OutputStream
data
- Data to encode and write; this method encodes and writes the
eight lower bits of this integer, and ignores the higher 24 bits.
IOException
- If the encoder is closed or the underlying stream has
a problem.public void write(byte[] data) throws IOException
Invoke this method to encode, and then write, the bytes contained in the input array to this stream.
write
in class OutputStream
data
- Data to write.
IOException
- If the encoder is closed or the underlying stream has
a problem.OutputStream.write(byte[], int, int)
public void write(byte[] data, int dataOffset, int dataLength) throws IOException
Invoke this method to encode, and then write, some bytes contained in the input array to this stream.
write
in class OutputStream
data
- Data to write.dataOffset
- First byte from provided array to encode and write.dataLength
- Number of bytes from provided array to encode and write.
IOException
- If the encoder is closed or the underlying stream has
a problem.public void flush() throws IOException
Invoke this method to force this stream to write out any data it has currently buffered.
Note: Eventually, you must invoke Base64OutputStream.close()
to
ensure that the output is padded correctly.
flush
in class OutputStream
IOException
- If the encoder is closed or the underlying stream has
a problem.public void close() throws IOException
Invoke this method to force this stream to write out all its buffered data, and close this stream and release any system resources it uses.
close
in class OutputStream
IOException
- If the underlying stream has a problem.public static String encodeAsString(byte[] input, int inputOffset, int inputLength, boolean insertCR, boolean insertLF) throws IOException
input
- The input data to encodeinputOffset
- The offset into the arrayinputLength
- The length of the arrayinsertCR
- Set to true if you want to insert a CR after every 76th encoded characterinsertLF
- Set to true if you want to insert a LF after every 76th encoded character
IOException
- Thrown if an encoding error occurredpublic static byte[] encode(byte[] input, int inputOffset, int inputLength, boolean insertCR, boolean insertLF) throws IOException
input
- The input data to encodeinputOffset
- The offset into the arrayinputLength
- The length of the arrayinsertCR
- Set to true if you want to insert a CR after every 76th encoded characterinsertLF
- Set to true if you want to insert a LF after every 76th encoded character
IOException
- Thrown if an encoding error occurred
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal