public class

UUEncoder

extends CharacterEncoder
java.lang.Object
   ↳ sun.misc.CharacterEncoder
     ↳ sun.misc.UUEncoder

Class Overview

This class implements a Berkeley uu character encoder. This encoder was made famous by uuencode program. The basic character coding is algorithmic, taking 6 bits of binary data and adding it to an ASCII ' ' (space) character. This converts these six bits into a printable representation. Note that it depends on the ASCII character encoding standard for english. Groups of three bytes are converted into 4 characters by treating the three bytes a four 6 bit groups, group 1 is byte 1's most significant six bits, group 2 is byte 1's least significant two bits plus byte 2's four most significant bits. etc. In this encoding, the buffer prefix is:

     begin [mode] [filename]
 
This is followed by one or more lines of the form:
      (len)(data)(data)(data) ...
 
where (len) is the number of bytes on this line. Note that groupings are always four characters, even if length is not a multiple of three bytes. When less than three characters are encoded, the values of the last remaining bytes is undefined and should be ignored. The last line of data in a uuencoded file is represented by a single space character. This is translated by the decoding engine to a line length of zero. This is immediately followed by a line which contains the word 'end[newline]'

Summary

[Expand]
Inherited Fields
From class sun.misc.CharacterEncoder
Public Constructors
UUEncoder()
Default - buffer begin line will be:
  begin 644 encoder.buf
 
UUEncoder(String fname)
Specifies a name for the encoded buffer, begin line will be:
  begin 644 [FNAME]
 
UUEncoder(String fname, int newMode)
Specifies a name and mode for the encoded buffer, begin line will be:
  begin [MODE] [FNAME]
 
Protected Methods
int bytesPerAtom()
number of bytes per atom in uuencoding is 3
int bytesPerLine()
number of bytes per line in uuencoding is 45
void encodeAtom(OutputStream outStream, byte[] data, int offset, int len)
encodeAtom - take three bytes and encodes them into 4 characters If len is less than 3 then remaining bytes are filled with '1'.
void encodeBufferPrefix(OutputStream a)
encodeBufferPrefix writes the begin line to the output stream.
void encodeBufferSuffix(OutputStream a)
encodeBufferSuffix writes the single line containing space (' ') and the line containing the word 'end' to the output stream.
void encodeLinePrefix(OutputStream outStream, int length)
Encode the line prefix which consists of the single character.
void encodeLineSuffix(OutputStream outStream)
The line suffix for uuencoded files is simply a new line.
[Expand]
Inherited Methods
From class sun.misc.CharacterEncoder
From class java.lang.Object

Public Constructors

public UUEncoder ()

Default - buffer begin line will be:

  begin 644 encoder.buf
 

public UUEncoder (String fname)

Specifies a name for the encoded buffer, begin line will be:

  begin 644 [FNAME]
 

public UUEncoder (String fname, int newMode)

Specifies a name and mode for the encoded buffer, begin line will be:

  begin [MODE] [FNAME]
 

Protected Methods

protected int bytesPerAtom ()

number of bytes per atom in uuencoding is 3

protected int bytesPerLine ()

number of bytes per line in uuencoding is 45

protected void encodeAtom (OutputStream outStream, byte[] data, int offset, int len)

encodeAtom - take three bytes and encodes them into 4 characters If len is less than 3 then remaining bytes are filled with '1'. This insures that the last line won't end in spaces and potentiallly be truncated.

Throws
IOException

protected void encodeBufferPrefix (OutputStream a)

encodeBufferPrefix writes the begin line to the output stream.

Throws
IOException

protected void encodeBufferSuffix (OutputStream a)

encodeBufferSuffix writes the single line containing space (' ') and the line containing the word 'end' to the output stream.

Throws
IOException

protected void encodeLinePrefix (OutputStream outStream, int length)

Encode the line prefix which consists of the single character. The lenght is added to the value of ' ' (32 decimal) and printed.

Throws
IOException

protected void encodeLineSuffix (OutputStream outStream)

The line suffix for uuencoded files is simply a new line.

Throws
IOException