public class Ascii85OutputStream
extends java.io.FilterOutputStream
An ascii85 encoder, implemented as an OutputStream
.
Call flush()
or close()
to properly close the
ascii85 block. The block must be closed for the encoded data to be valid.
Do not call flush()
before you intend to end the ascii85 block.
Multiple ascii85 blocks may be encoded by calling flush() and then writing
more bytes to the stream.
Note that if you use the constructor with the
useSpaceCompression
option, the encoded text will be shorter
when there are many consecutive space characters in the encoded data, but
it will not be compatible with Adobe's ascii85 implementation. It makes sense
to use this option if interoperability with other ascii85 implementations
is not a requirement.
Constructor and Description |
---|
Ascii85OutputStream(java.io.OutputStream out)
Creates an output stream to encode ascii85 data, using a default line
with of 72 characters and not using the space character compression
option.
|
Ascii85OutputStream(java.io.OutputStream out,
boolean useSpaceCompression)
Creates an output stream to encode ascii85 data, using a default line
width of 72 characters.
|
Ascii85OutputStream(java.io.OutputStream out,
int width,
boolean useSpaceCompression)
Creates an output stream to encode ascii85 data.
|
Modifier and Type | Method and Description |
---|---|
void |
flush()
Adds the closing block and flushes the underlying output stream.
|
void |
write(int b)
Writes a single byte to the stream.
|
void |
writeUnencoded(byte[] b)
Writes bytes to the underlying output stream, unencoded.
|
void |
writeUnencoded(byte[] b,
int off,
int len)
Writes bytes to the underlying output stream, unencoded.
|
void |
writeUnencoded(int b)
Writes a single byte to the underlying output stream, unencoded.
|
public Ascii85OutputStream(java.io.OutputStream out)
flush()
to add the padding and end the ascii85
block.out
- the output stream.public Ascii85OutputStream(java.io.OutputStream out, boolean useSpaceCompression)
flush()
to end the ascii85
block.out
- the output stream.useSpaceCompression
- Whether to use space character compression in
the output.public Ascii85OutputStream(java.io.OutputStream out, int width, boolean useSpaceCompression)
flush()
to end the ascii85 block.out
- the output stream.width
- The maximum line width of the encoded output text.
Whitespace characters are ignored when decoding.useSpaceCompression
- Whether to use space character compression in
the output.public void write(int b) throws java.io.IOException
OutputStream.write(int b)
for details.write
in class java.io.FilterOutputStream
b
- The byte to encode.java.io.IOException
- If an I/O error occurs in the underlying
output stream.public void writeUnencoded(int b) throws java.io.IOException
b
- The byte to write.java.io.IOException
- If the underlying output stream has an I/O
error.public void writeUnencoded(byte[] b) throws java.io.IOException
b
- The bytes to write.java.io.IOException
- If the underlying output stream has an I/O
error.public void writeUnencoded(byte[] b, int off, int len) throws java.io.IOException
b
- The bytes to write.off
- The offset of b
to start reading from.len
- The amount of bytes to read from b
.java.io.IOException
- If the underlying output stream has an I/O
error.public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.FilterOutputStream
java.io.IOException