Enum Base64

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Base64>

    public enum Base64
    extends java.lang.Enum<Base64>
    Provides Base64 encoding and decoding as defined by RFC 2045.

    This class implements section 6.8. Base64 Content-Transfer-Encoding from RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies by Freed and Borenstein.

    See Also:
    RFC 2045
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] decodeBase64​(byte[] base64Data)
      Decodes Base64 data into octects
      static byte[] encodeBase64​(byte[] binaryData)
      Encodes binary data using the base64 algorithm but does not chunk the output.
      static byte[] encodeBase64​(byte[] binaryData, boolean isChunked)
      Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
      static Base64 valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static Base64[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • values

        public static Base64[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Base64 c : Base64.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Base64 valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • encodeBase64

        public static byte[] encodeBase64​(byte[] binaryData)
        Encodes binary data using the base64 algorithm but does not chunk the output.
        Parameters:
        binaryData - binary data to encode
        Returns:
        Base64 characters
      • encodeBase64

        public static byte[] encodeBase64​(byte[] binaryData,
                                          boolean isChunked)
        Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
        Parameters:
        binaryData - Array containing binary data to encode.
        isChunked - if true this encoder will chunk the base64 output into 76 character blocks
        Returns:
        Base64-encoded data.
      • decodeBase64

        public static byte[] decodeBase64​(byte[] base64Data)
        Decodes Base64 data into octects
        Parameters:
        base64Data - Byte array containing Base64 data
        Returns:
        Array containing decoded data.