Class Base64


  • public class Base64
    extends java.lang.Object
    Class to manage straight and stream conversions to and from base64 encoding.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String _rcsid  
      protected byte[] byteBuffer
      This is a byte buffer which is needed during the encoding process.
      protected char[] characterBuffer
      This is a character buffer which is needed during the decoding process.
    • Constructor Summary

      Constructors 
      Constructor Description
      Base64()
      Construct the encoder/decoder.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean decodeNextWord​(java.io.Reader inputBuffer, java.io.OutputStream outputBuffer)
      Decode the next base64 character.
      void decodeStream​(java.io.Reader inputBuffer, java.io.OutputStream outputBuffer)
      Decode an entire stream.
      byte[] decodeString​(java.lang.String inputString)
      Decode a string into a byte array.
      java.lang.String encodeByteArray​(byte[] inputByteArray)
      Encode a byte array to a string.
      boolean encodeNextWord​(java.io.InputStream inputStream, java.io.Writer outputWriter)
      Encode a single word.
      void encodeStream​(java.io.InputStream inputStream, java.io.Writer outputWriter)
      Encode a full stream, to the end.
      • Methods inherited from class java.lang.Object

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

      • characterBuffer

        protected char[] characterBuffer
        This is a character buffer which is needed during the decoding process.
      • byteBuffer

        protected byte[] byteBuffer
        This is a byte buffer which is needed during the encoding process.
    • Constructor Detail

      • Base64

        public Base64()
        Construct the encoder/decoder.
    • Method Detail

      • decodeNextWord

        public boolean decodeNextWord​(java.io.Reader inputBuffer,
                                      java.io.OutputStream outputBuffer)
                               throws ManifoldCFException
        Decode the next base64 character. Reads a single encoded word from the input stream, and writes the decoded word to the output.
        Parameters:
        inputBuffer - is the character input stream.
        outputBuffer - is the binary output stream.
        Returns:
        false if end-of-stream encountered, true otherwise
        Throws:
        ManifoldCFException
      • decodeStream

        public void decodeStream​(java.io.Reader inputBuffer,
                                 java.io.OutputStream outputBuffer)
                          throws ManifoldCFException
        Decode an entire stream.
        Parameters:
        inputBuffer - is the character input stream.
        outputBuffer - is the binary output stream.
        Throws:
        ManifoldCFException
      • decodeString

        public byte[] decodeString​(java.lang.String inputString)
                            throws ManifoldCFException
        Decode a string into a byte array.
        Parameters:
        inputString - is the string.
        Returns:
        a corresponding byte array.
        Throws:
        ManifoldCFException
      • encodeNextWord

        public boolean encodeNextWord​(java.io.InputStream inputStream,
                                      java.io.Writer outputWriter)
                               throws ManifoldCFException
        Encode a single word.
        Parameters:
        inputStream - is the input binary data.
        outputWriter - is the character output stream.
        Returns:
        false if end-of-stream encountered, true otherwise.
        Throws:
        ManifoldCFException
      • encodeStream

        public void encodeStream​(java.io.InputStream inputStream,
                                 java.io.Writer outputWriter)
                          throws ManifoldCFException
        Encode a full stream, to the end.
        Parameters:
        inputStream - is the input stream.
        outputWriter - is the output writer.
        Throws:
        ManifoldCFException
      • encodeByteArray

        public java.lang.String encodeByteArray​(byte[] inputByteArray)
                                         throws ManifoldCFException
        Encode a byte array to a string.
        Parameters:
        inputByteArray - is the byte array.
        Returns:
        the encoded string.
        Throws:
        ManifoldCFException