Class Base64Decoder


  • final class Base64Decoder
    extends java.lang.Object
    Since:
    1.3
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static byte[] DECODING_TABLE
      Set up the decoding table; this is indexed by a byte converted to an unsigned int, so must be at least as large as the number of different byte values, positive and negative and zero.
      private static byte[] ENCODING_TABLE
      Set up the encoding table.
      private static int INPUT_BYTES_PER_CHUNK
      Number of bytes per encoded chunk - 4 6bit bytes produce 3 8bit bytes on output.
      private static int INVALID_BYTE
      Decoding table value for invalid bytes.
      private static int MASK_BYTE_UNSIGNED
      Mask to treat byte as unsigned integer.
      private static int PAD_BYTE
      Decoding table value for padding bytes, so can detect PAD afer conversion.
      private static byte PADDING
      The padding byte.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Base64Decoder()
      Hidden constructor, this class must not be instantiated.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int decode​(byte[] data, java.io.OutputStream out)
      Decode the base 64 encoded byte data writing it to the given output stream, whitespace characters will be ignored.
      • Methods inherited from class java.lang.Object

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

      • INVALID_BYTE

        private static final int INVALID_BYTE
        Decoding table value for invalid bytes.
        See Also:
        Constant Field Values
      • PAD_BYTE

        private static final int PAD_BYTE
        Decoding table value for padding bytes, so can detect PAD afer conversion.
        See Also:
        Constant Field Values
      • MASK_BYTE_UNSIGNED

        private static final int MASK_BYTE_UNSIGNED
        Mask to treat byte as unsigned integer.
        See Also:
        Constant Field Values
      • INPUT_BYTES_PER_CHUNK

        private static final int INPUT_BYTES_PER_CHUNK
        Number of bytes per encoded chunk - 4 6bit bytes produce 3 8bit bytes on output.
        See Also:
        Constant Field Values
      • ENCODING_TABLE

        private static final byte[] ENCODING_TABLE
        Set up the encoding table.
      • DECODING_TABLE

        private static final byte[] DECODING_TABLE
        Set up the decoding table; this is indexed by a byte converted to an unsigned int, so must be at least as large as the number of different byte values, positive and negative and zero.
    • Constructor Detail

      • Base64Decoder

        private Base64Decoder()
        Hidden constructor, this class must not be instantiated.
    • Method Detail

      • decode

        public static int decode​(byte[] data,
                                 java.io.OutputStream out)
                          throws java.io.IOException
        Decode the base 64 encoded byte data writing it to the given output stream, whitespace characters will be ignored.
        Parameters:
        data - the buffer containing the Base64-encoded data
        out - the output stream to hold the decoded bytes
        Returns:
        the number of bytes produced.
        Throws:
        java.io.IOException - thrown when the padding is incorrect or the input is truncated.