Class Base64


  • public class Base64
    extends java.lang.Object
    Routines for encoding and decoding objects using the base64 encoding.
    • Constructor Summary

      Constructors 
      Constructor Description
      Base64()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String decode​(java.lang.String string)
      Decodes a base64-encoded string.
      static java.lang.String decode​(java.lang.String string, java.lang.String characterSet)
      Decodes a base64-encoded string based on CharacterSet.
      static byte[] decodeToBytes​(java.lang.String string)
      Decodes a base64-encoded string to a byte array.
      static java.lang.String encode​(byte[] data)
      Encodes data using the base64 encoding.
      static java.lang.String encode​(java.lang.String string)
      Encodes a string using the base64 encoding.
      static java.lang.String encode​(java.lang.String string, java.lang.String charset)
      Encodes a string using the base64 encoding based on given character set.
      static void main​(java.lang.String[] args)
      Mainline for testing.
      • Methods inherited from class java.lang.Object

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

      • Base64

        public Base64()
    • Method Detail

      • encode

        public static java.lang.String encode​(java.lang.String string)
        Encodes a string using the base64 encoding.
        Parameters:
        string - a string
        Returns:
        the base64-encoded string.
      • encode

        public static java.lang.String encode​(java.lang.String string,
                                              java.lang.String charset)
        Encodes a string using the base64 encoding based on given character set.
        Parameters:
        string - a string.
        charset - character set to encode given string.
        Returns:
        the base64-encoded string.
      • encode

        public static java.lang.String encode​(byte[] data)
        Encodes data using the base64 encoding.
        Parameters:
        data - the data
        Returns:
        the base64-encoded string.
      • decode

        public static java.lang.String decode​(java.lang.String string)
        Decodes a base64-encoded string. Note: this method should be used only in situations where the original message doesn't contain non-visible characters. If the original messge (to be encoded) contains non-visible characters, use @link <code>decodeBytes</code> instead.
        Parameters:
        string - the string to be decoded.
        Returns:
        the decoded string.
      • decode

        public static java.lang.String decode​(java.lang.String string,
                                              java.lang.String characterSet)
        Decodes a base64-encoded string based on CharacterSet. Note: this method should be used only in situations where the original message doesn't contain non-visible characters. If the original message (to be encoded) contains non-visible characters, use @link <code>decodeBytes</code> instead.
        Parameters:
        string - the string to be decoded.
        characterSet - supported CharacterSet.
        Returns:
        the decoded string.
      • decodeToBytes

        public static byte[] decodeToBytes​(java.lang.String string)
        Decodes a base64-encoded string to a byte array.
        Parameters:
        string - the string to be decoded.
        Returns:
        a byte array.
      • main

        public static void main​(java.lang.String[] args)
        Mainline for testing.