org.spaceroots.jarmor
Class ASCII85Encoder

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.FilterOutputStream
          extended byorg.spaceroots.jarmor.ASCII85Encoder

public class ASCII85Encoder
extends FilterOutputStream

This class encodes a binary stream into a text stream.

The ASCII85encoding is suitable when binary data needs to be transmitted or stored as text. It has been defined by Adobe for the PostScript and PDF formats (see PDF Reference, section 3.3 Details of Filtered Streams).

The encoded stream is about 25% larger than the corresponding binary stream (32 binary bits are converted into 40 encoded bits, and there may be start/end of line markers).

Author:
Luc Maisonobe
See Also:
ASCII85Decoder

Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
ASCII85Encoder(OutputStream out)
          Create an encoder wrapping a sink of binary data.
ASCII85Encoder(OutputStream out, int lineLength, byte[] sol, byte[] eol)
          Create an encoder wrapping a sink of binary data.
 
Method Summary
 void close()
          Closes this output stream and releases any system resources associated with the stream.
 void write(int b)
          Writes the specified byte to this output stream.
 
Methods inherited from class java.io.FilterOutputStream
flush, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ASCII85Encoder

public ASCII85Encoder(OutputStream out)
Create an encoder wrapping a sink of binary data.

Calling this constructor is equivalent to calling ASCII85Encoder(out, -1, null, null).

Parameters:
out - sink of binary data to filter

ASCII85Encoder

public ASCII85Encoder(OutputStream out,
                      int lineLength,
                      byte[] sol,
                      byte[] eol)
Create an encoder wrapping a sink of binary data.

The additional arguments allow to specify some text formatting

Note that specifying a negative number for lineLength is really equivalent to calling the one argument constructor.

If non-null start/end of line are used, they must contain only whitespace characters as other characters would otherwise interfere with the decoding process on the other side of the channel. For safety, it is recommended to stick to space (' ', 0x32) and horizontal tabulation ('\t', 0x9) characters for the start of line marker, and to line feed ('\n', 0xa) and carriage return ('\r', 0xd) characters according to the platform convention for the end of line marker.

Parameters:
out - sink of binary data to filter
lineLength - maximal length of a ligne (counting sol but not counting eol), if negative lines will not be split
sol - start of line marker to use (mainly for indentation purposes), may be null
eol - end of line marker to use, may be null only if lineLength is negative
Method Detail

close

public void close()
           throws IOException
Closes this output stream and releases any system resources associated with the stream.

Throws:
IOException - if the underlying stream throws one

write

public void write(int b)
           throws IOException
Writes the specified byte to this output stream.

Parameters:
b - byte to write (only the 8 low order bits are used)
Throws:
IOException


Copyright © 2005-2006 Luc Maisonobe. All Rights Reserved.