Package android.util

Class Base64OutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class Base64OutputStream
    extends java.io.FilterOutputStream
    An OutputStream that does Base64 encoding on the data written to it, writing the resulting data to another OutputStream.
    • Field Summary

      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor Description
      Base64OutputStream​(java.io.OutputStream out, int options)
      Performs Base64 encoding on the data written to the stream, writing the encoded data to another OutputStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Encodes and writes the remaining buffered bytes, adds necessary padding, and closes the output stream.
      void flush()
      Flushed the enclosed output stream, but does not write uncompleted 4-blocks.
      void write​(int theByte)
      Writes the byte to the output stream after converting to/from Base64 notation.
      • Methods inherited from class java.io.FilterOutputStream

        write, write
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Base64OutputStream

        public Base64OutputStream​(java.io.OutputStream out,
                                  int options)
        Performs Base64 encoding on the data written to the stream, writing the encoded data to another OutputStream.
        Parameters:
        out - the OutputStream to write the encoded data to
        options - bit flags for controlling the encoder; see the constants in Base64
    • Method Detail

      • write

        public void write​(int theByte)
                   throws java.io.IOException
        Writes the byte to the output stream after converting to/from Base64 notation. When encoding, bytes are buffered three at a time before the output stream actually gets a write() call. When decoding, bytes are buffered four at a time.
        Overrides:
        write in class java.io.FilterOutputStream
        Parameters:
        theByte - the byte to write.
        Throws:
        java.io.IOException - when unable to write data.
      • flush

        public void flush()
                   throws java.io.IOException
        Flushed the enclosed output stream, but does not write uncompleted 4-blocks. To ensure consistency that only happens on close.
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.FilterOutputStream
        Throws:
        java.io.IOException - If unable to write to the output stream.
      • close

        public void close()
                   throws java.io.IOException
        Encodes and writes the remaining buffered bytes, adds necessary padding, and closes the output stream. Does nothing if the stream is already closed.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.FilterOutputStream
        Throws:
        java.io.IOException - If unable to write the remaining bytes or close the stream.