Class Base64


  • public class Base64
    extends java.lang.Object
    This class delegates to either javax.xml.bind.DatatypeConverter (for Java < 8) or java.util.Base64 (Java 8+) to perform Base64 encoding of a String. This code requires Java 8+ for compilation.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static boolean HAS_JAVA_UTIL_BASE64  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Base64()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String encodeToString​(byte[] src)
      Encodes a byte[] to a String using Base64.
      private static boolean hasJavaUtilBase64()  
      • Methods inherited from class java.lang.Object

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

      • HAS_JAVA_UTIL_BASE64

        private static final boolean HAS_JAVA_UTIL_BASE64
    • Constructor Detail

      • Base64

        private Base64()
    • Method Detail

      • hasJavaUtilBase64

        private static boolean hasJavaUtilBase64()
      • encodeToString

        public static java.lang.String encodeToString​(byte[] src)
        Encodes a byte[] to a String using Base64. Passing a null argument will cause a NullPointerException to be thrown.
        Parameters:
        src - string to be encoded
        Returns:
        String in Base64 encoding