Package com.sun.mail.util
Class UUEncoderStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- com.sun.mail.util.UUEncoderStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class UUEncoderStream extends java.io.FilterOutputStreamThis 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.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]bufferprivate intbufsizeprivate intmodeprivate java.lang.Stringnameprivate booleanwrotePrefixprivate booleanwroteSuffix
-
Constructor Summary
Constructors Constructor Description UUEncoderStream(java.io.OutputStream out)Create a UUencoder that encodes the specified input streamUUEncoderStream(java.io.OutputStream out, java.lang.String name)Create a UUencoder that encodes the specified input streamUUEncoderStream(java.io.OutputStream out, java.lang.String name, int mode)Create a UUencoder that encodes the specified input stream
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()private voidencode()Encode a line.voidflush()voidsetNameMode(java.lang.String name, int mode)Set up the buffer name and permission mode.voidwrite(byte[] data)voidwrite(byte[] b, int off, int len)voidwrite(int c)private voidwritePrefix()Write out the prefix: "begin" private voidwriteSuffix()Write a single line containing space and the suffix line containing the single word "end" (terminated by a newline)
-
-
-
Constructor Detail
-
UUEncoderStream
public UUEncoderStream(java.io.OutputStream out)
Create a UUencoder that encodes the specified input stream- Parameters:
out- the output stream
-
UUEncoderStream
public UUEncoderStream(java.io.OutputStream out, java.lang.String name)Create a UUencoder that encodes the specified input stream- Parameters:
out- the output streamname- Specifies a name for the encoded buffer
-
UUEncoderStream
public UUEncoderStream(java.io.OutputStream out, java.lang.String name, int mode)Create a UUencoder that encodes the specified input stream- Parameters:
out- the output streamname- Specifies a name for the encoded buffermode- Specifies permission mode for the encoded buffer
-
-
Method Detail
-
setNameMode
public void setNameMode(java.lang.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- the buffer namemode- the permission mode
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] data) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
write
public void write(int c) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
writePrefix
private void writePrefix() throws java.io.IOExceptionWrite out the prefix: "begin" - Throws:
java.io.IOException
-
writeSuffix
private void writeSuffix() throws java.io.IOExceptionWrite a single line containing space and the suffix line containing the single word "end" (terminated by a newline)- Throws:
java.io.IOException
-
encode
private void encode() throws java.io.IOExceptionEncode 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.- Throws:
java.io.IOException
-
-