Top Description Fields Constructors Methods
com.sun.mail.util

public Class UUEncoderStream

extends FilterOutputStream
Class Inheritance
Imports
java.io.*

This class implements a UUEncoder. It is implemented as a FilterOutputStream, so one can just wrap this class around any output stream and write bytes into this filter. The Encoding is done as the bytes are written out.
Author
John Mani

Field Summary

Modifier and TypeField and Description
private byte[]
private int
private int
private String
private boolean
private boolean
Inherited from java.io.FilterOutputStream:
out

Constructor Summary

AccessConstructor and Description
public
UUEncoderStream(OutputStream
the output stream
out
)

Create a UUencoder that encodes the specified input stream

public
UUEncoderStream(OutputStream
the output stream
out
,
String
Specifies a name for the encoded buffer
name
)

Create a UUencoder that encodes the specified input stream

public
UUEncoderStream(OutputStream
the output stream
out
,
String
Specifies a name for the encoded buffer
name
,
int
Specifies permission mode for the encoded buffer
mode
)

Create a UUencoder that encodes the specified input stream

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with the stream.
private void
encode()

Encode a line.

public void
flush()

Overrides java.io.FilterOutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream and forces any buffered output bytes to be written out to the stream.
public void
setNameMode(String
the buffer name
name
,
int
the permission mode
mode
)

Set up the buffer name and permission mode.

public void
write(byte[]
the data.
b
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.
public void
write(byte[]
the data to be written.
data
)

Overrides java.io.FilterOutputStream.write.

Writes b.length bytes to this output stream.
public void
write(int
the byte.
c
)

Overrides java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.
private void
writePrefix()

Write out the prefix: "begin <mode> <name>"

private void
writeSuffix()

Write a single line containing space and the suffix line containing the single word "end" (terminated by a newline)

Field Detail

bufferback to summary
private byte[] buffer
bufsizeback to summary
private int bufsize
modeback to summary
private int mode
nameback to summary
private String name
wrotePrefixback to summary
private boolean wrotePrefix
wroteSuffixback to summary
private boolean wroteSuffix

Constructor Detail

UUEncoderStreamback to summary
public UUEncoderStream(OutputStream out)

Create a UUencoder that encodes the specified input stream

Parameters
out:OutputStream

the output stream

UUEncoderStreamback to summary
public UUEncoderStream(OutputStream out, String name)

Create a UUencoder that encodes the specified input stream

Parameters
out:OutputStream

the output stream

name:String

Specifies a name for the encoded buffer

UUEncoderStreamback to summary
public UUEncoderStream(OutputStream out, String name, int mode)

Create a UUencoder that encodes the specified input stream

Parameters
out:OutputStream

the output stream

name:String

Specifies a name for the encoded buffer

mode:int

Specifies permission mode for the encoded buffer

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.FilterOutputStream.close.

Closes this output stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
encodeback to summary
private void encode() throws IOException

Encode a line. Start off with the character count, followed by the encoded atoms and terminate with LF. (or is it CRLF or the local line-terminator ?) Take three bytes and encodes them into 4 characters If bufsize if not a multiple of 3, the remaining bytes are filled with '1'. This insures that the last line won't end in spaces and potentiallly be truncated.

flushback to summary
public void flush() throws IOException

Overrides java.io.FilterOutputStream.flush.

Implements java.io.Flushable.flush.

Doc from java.io.FilterOutputStream.flush.

Flushes this output stream and forces any buffered output bytes to be written out to the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
setNameModeback to summary
public void setNameMode(String name, int mode)

Set up the buffer name and permission mode. This method has any effect only if it is invoked before you start writing into the output stream

Parameters
name:String

the buffer name

mode:int

the permission mode

writeback to summary
public void write(byte[] b, int off, int len) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Parameters
b:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(byte[] data) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes b.length bytes to this output stream.

Parameters
data:byte[]

the data to be written.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(int c) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.

The write method of FilterOutputStream calls the write method of its underlying output stream, that is, it performs out.write(b).

Implements the abstract write method of OutputStream.

Parameters
c:int

the byte.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
writePrefixback to summary
private void writePrefix() throws IOException

Write out the prefix: "begin "

writeSuffixback to summary
private void writeSuffix() throws IOException

Write a single line containing space and the suffix line containing the single word "end" (terminated by a newline)