|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.OutputStream | +--java.io.FilterOutputStream | +--iaik.utils.Base64OutputStream
This class represents a FilterOutputStream that Base64 encodes the data
passing through it. For writing Base64 encoded data to the underlying
output stream, use one of the write
methods.
Base64 is the encoding format used by Multipurpose Internet Mail Extension (Mime) for transmitting non-text material over text-only communications channels. Base64 is based on a 65-character subset of US-ASCII, enabling 6 bits to be represented per printable character (see RFC 1521).
This class may be used for Base64 encoding some given data and writing it to a file, e.g.:
FileOutputStream fos = new FileOutputStream("test/base64.enc"); Base64OutputStream base64os = new Base64OutputStream(fos); byte[] data = "Test Data to be Base64 encoded and written to a file".getBytes(); base64os.write(data); base64os.flush(); base64os.close();
Base64InputStream
Fields inherited from class java.io.FilterOutputStream |
out |
Constructor Summary | |
Base64OutputStream(OutputStream out)
Creates a new Base64OutputStream to write Base64 encoded data to the specified underlying output stream. |
|
Base64OutputStream(OutputStream out,
byte[] lineBreak)
Creates a new Base64OutputStream to write Base64 encoded data to the specified underlying output stream. |
Method Summary | |
void |
flush()
Performs final processing and output to the output stream. |
static byte[] |
getLineBreak()
Gets the line break delimiter; is CRLF (0x0D, 0x0A). |
static void |
setLineBreak(byte[] lineBreak)
Stets the lineBreak delimiter to be used throughout the application; default is CRLF (0x0D, 0x0A). |
void |
write(byte[] in,
int inOff,
int inLen)
Base64 encodes the the specified number of bytes and writes them to the underlying output stream. |
void |
write(int b)
Base64 encodes the given byte and writes it to the underlying output stream. |
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 |
Constructor Detail |
public Base64OutputStream(OutputStream out, byte[] lineBreak)
out
- - the underlying output stream.lineBreak
- - the lineBreak the line break delimiter to be used; if null
or of zero length, the currently static set line break delimiter
CRLF (0x0D, 0x0A) will be usedpublic Base64OutputStream(OutputStream out)
out
- - the underlying output stream.Method Detail |
public static void setLineBreak(byte[] lineBreak)
lineBreak
- the lineBreak to be usedIllegalArgumentException
- if lineBreak is null
or of zero lengthpublic static byte[] getLineBreak()
public void write(int b) throws IOException
write
in class FilterOutputStream
b
- the byte to be Base64 encoded.IOException
- if an I/O error occurs.public void write(byte[] in, int inOff, int inLen) throws IOException
The data to be processed is given in an input byte array. Beginning at
inOff
, this method only encodes the first inLen
bytes and writes them to the underlying output stream.
write
in class FilterOutputStream
in
- the buffer containing the bytes to be Base64 encodedinOff
- the offset indicating the start position within the input byte arrayinLen
- the number of bytes to be processedIOException
- if an I/O error occurs.public void flush() throws IOException
flush
in class FilterOutputStream
IOException
- If an error occurs.
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |