edu.vt.middleware.crypt.io
Class Base64FilterOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by edu.vt.middleware.crypt.io.AbstractEncodingFilterOutputStream
              extended by edu.vt.middleware.crypt.io.Base64FilterOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class Base64FilterOutputStream
extends AbstractEncodingFilterOutputStream

Encodes raw bytes into base-64 encoded character bytes in the wrapped output stream.

Version:
$Revision: 2744 $
Author:
Middleware Services

Field Summary
static int LINE_LENGTH_64
          Wrap lines at 64 characters.
static int LINE_LENGTH_76
          Wrap lines at 76 characters.
static char LINE_TERMINATOR
          Line termination character.
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
Base64FilterOutputStream(OutputStream out)
          Creates a base-64 filter output stream around the given output stream.
Base64FilterOutputStream(OutputStream out, int charsPerLine)
          /** Creates a base-64 filter output stream around the given output stream.
 
Method Summary
 void close()
          
protected  void flushToStream()
          Encodes the contents of the write buffer and writes the result to the wrapped output stream.
protected  void writeEncoded(byte[] data, int offset, int length)
          Encode the given raw bytes and write the result to the wrapped output stream.
 
Methods inherited from class edu.vt.middleware.crypt.io.AbstractEncodingFilterOutputStream
write, write, write
 
Methods inherited from class java.io.FilterOutputStream
flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_LENGTH_64

public static final int LINE_LENGTH_64
Wrap lines at 64 characters.

See Also:
Constant Field Values

LINE_LENGTH_76

public static final int LINE_LENGTH_76
Wrap lines at 76 characters.

See Also:
Constant Field Values

LINE_TERMINATOR

public static final char LINE_TERMINATOR
Line termination character.

See Also:
Constant Field Values
Constructor Detail

Base64FilterOutputStream

public Base64FilterOutputStream(OutputStream out)
Creates a base-64 filter output stream around the given output stream.

Parameters:
out - Output stream to wrap.

Base64FilterOutputStream

public Base64FilterOutputStream(OutputStream out,
                                int charsPerLine)
/** Creates a base-64 filter output stream around the given output stream.

Parameters:
out - Output stream to wrap.
charsPerLine - Number of characters per line of encoded output. Must be one of LINE_LENGTH_64, LINE_LENGTH_76, or 0 to indicate no wrapping.
Method Detail

close

public void close()
           throws IOException

Specified by:
close in interface Closeable
Overrides:
close in class FilterOutputStream
Throws:
IOException

writeEncoded

protected void writeEncoded(byte[] data,
                            int offset,
                            int length)
                     throws IOException
Encode the given raw bytes and write the result to the wrapped output stream.

Specified by:
writeEncoded in class AbstractEncodingFilterOutputStream
Parameters:
data - Raw bytes to be encoded and written.
offset - Starting index of data to be written in input byte array.
length - Number of bytes to be written from input byte array.
Throws:
IOException - On write errors.

flushToStream

protected void flushToStream()
                      throws IOException
Encodes the contents of the write buffer and writes the result to the wrapped output stream.

Throws:
IOException - On write errors.


Copyright © 2003-2013 Virginia Tech. All Rights Reserved.