Class Base64FilterOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

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 Details

    • LINE_LENGTH_64

      public static final int LINE_LENGTH_64
      Wrap lines at 64 characters.
      See Also:
    • LINE_LENGTH_76

      public static final int LINE_LENGTH_76
      Wrap lines at 76 characters.
      See Also:
    • LINE_TERMINATOR

      public static final char LINE_TERMINATOR
      Line termination character.
      See Also:
  • Constructor Details

    • 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 Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      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.