org.spaceroots.jarmor
Class UUEncoder

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

public class UUEncoder
extends FilterOutputStream

This class encodes a binary stream into a text stream.

The UU encoding is suitable when binary data needs to be transmitted or stored as text. It was used to send binary data through UUCP (Unix to Unix Copy Protocol). The encoded text uses a subset of the ASCII character set.

The encoded stream is about 38% larger than the corresponding binary stream (6 binary bits are converted into 8 encoded bits, there are stream header and trailer, and each 60 encoded bytes chunk is started by a control character and ended by a newline).

Author:
Luc Maisonobe
See Also:
UUDecoder

Field Summary
static int EXECUTE
          Bit-pattern for EXECUTE permission.
static int READ
          Bit-pattern for READ permission.
static int WRITE
          Bit-pattern for WRITE permission.
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
UUEncoder(OutputStream out)
          Create an encoder wrapping a sink of binary data.
UUEncoder(OutputStream out, String name, int userPerms, int groupPerms, int othersPerms)
          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
 

Field Detail

READ

public static final int READ
Bit-pattern for READ permission.

See Also:
Constant Field Values

WRITE

public static final int WRITE
Bit-pattern for WRITE permission.

See Also:
Constant Field Values

EXECUTE

public static final int EXECUTE
Bit-pattern for EXECUTE permission.

See Also:
Constant Field Values
Constructor Detail

UUEncoder

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

The encoder built will have a default name of "decoded.data" and default permissions set to READ|WRITE for the user, READ for the group and READ for others.

Parameters:
out - sink of binary data to filter

UUEncoder

public UUEncoder(OutputStream out,
                 String name,
                 int userPerms,
                 int groupPerms,
                 int othersPerms)
Create an encoder wrapping a sink of binary data.

The name and the various permission listed here are relevant if the data is to be stored on a file once decoded. The permissions are specified by or-ing together the desired bits patterns READ, WRITE and EXECUTE.

Parameters:
out - sink of binary data to filter
name - name of the data file
userPerms - access permission for the user (owner)
groupPerms - access permission for the group
othersPerms - access permission for others
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.