Class Base64EncoderStream

java.lang.Object
java.io.OutputStream
org.apache.batik.util.Base64EncoderStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class Base64EncoderStream extends OutputStream
This class implements a Base64 Character encoder as specified in RFC1113. Unlike some other encoding schemes there is nothing in this encoding that indicates where a buffer starts or ends. This means that the encoded text will simply start with the first line of encoded text and end with the last line of encoded text.
Version:
$Id: Base64EncoderStream.java 1733416 2016-03-03 07:07:13Z gadams $
  • Field Details

    • pem_array

      private static final byte[] pem_array
      This array maps the 6 bit values to their characters
    • atom

      byte[] atom
    • atomLen

      int atomLen
    • encodeBuf

      byte[] encodeBuf
    • lineLen

      int lineLen
    • out

    • closeOutOnClose

      boolean closeOutOnClose
  • Constructor Details

    • Base64EncoderStream

      public Base64EncoderStream(OutputStream out)
    • Base64EncoderStream

      public Base64EncoderStream(OutputStream out, boolean closeOutOnClose)
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException
    • flush

      public void flush() throws IOException
      This can't really flush out output since that may generate '=' chars which would indicate the end of the stream. Instead we flush out. You can only be sure all output is writen by closing this stream.
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
      Throws:
      IOException
    • write

      public void write(int b) throws IOException
      Specified by:
      write in class OutputStream
      Throws:
      IOException
    • write

      public void write(byte[] data) throws IOException
      Overrides:
      write in class OutputStream
      Throws:
      IOException
    • write

      public void write(byte[] data, int off, int len) throws IOException
      Overrides:
      write in class OutputStream
      Throws:
      IOException
    • encodeAtom

      void encodeAtom() throws IOException
      enocodeAtom - Take three bytes of input and encode it as 4 printable characters. Note that if the length in len is less than three is encodes either one or two '=' signs to indicate padding characters.
      Throws:
      IOException
    • encodeFromArray

      void encodeFromArray(byte[] data, int offset, int len) throws IOException
      enocodeAtom - Take three bytes of input and encode it as 4 printable characters. Note that if the length in len is less than three is encodes either one or two '=' signs to indicate padding characters.
      Throws:
      IOException