Class Base64Utils


  • public class Base64Utils
    extends java.lang.Object
    A utility to decode and encode byte arrays as Strings, using only "safe" characters.
    • Constructor Summary

      Constructors 
      Constructor Description
      Base64Utils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] fromBase64​(java.lang.String data)
      Decode a base64 string into a byte array.
      static long longFromBase64​(java.lang.String value)
      Decode a base64 string into a long value.
      static java.lang.String toBase64​(byte[] data)
      Converts a byte array into a base 64 encoded string.
      static java.lang.String toBase64​(long value)
      Return a string containing a base-64 encoded version of the given long value.
      • Methods inherited from class java.lang.Object

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

      • Base64Utils

        public Base64Utils()
    • Method Detail

      • fromBase64

        public static byte[] fromBase64​(java.lang.String data)
        Decode a base64 string into a byte array.
        Parameters:
        data - the encoded data.
        Returns:
        a byte array.
        See Also:
        fromBase64(String)
      • longFromBase64

        public static long longFromBase64​(java.lang.String value)
        Decode a base64 string into a long value.
      • toBase64

        public static java.lang.String toBase64​(byte[] data)
        Converts a byte array into a base 64 encoded string. Null is encoded as null, and an empty array is encoded as an empty string. Otherwise, the byte data is read 3 bytes at a time, with bytes off the end of the array padded with zeros. Each 24-bit chunk is encoded as 4 characters from the sequence [A-Za-z0-9$_]. If one of the source positions consists entirely of padding zeros, an '=' character is used instead.
        Parameters:
        data - a byte array, which may be null or empty
        Returns:
        a String
      • toBase64

        public static java.lang.String toBase64​(long value)
        Return a string containing a base-64 encoded version of the given long value. Leading groups of all zero bits are omitted.