Class Base64Tool


  • public class Base64Tool
    extends java.lang.Object
    Base 64 toolbox
    This class only provides static variables and methods
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String byteArrayToAltBase64​(byte[] a)
      Translates the specified byte array into an "aternate representation"
      Base64 string.
      static java.lang.String byteArrayToBase64​(byte[] a)
      Translates the specified byte array into a Base64 string as per Preferences.put(byte[])
      static byte[] decode​(char[] in)
      Decodes a byte array from Base64 format.
      static byte[] decode​(java.lang.String s)
      Decodes a byte array from Base64 format
      static java.lang.String decodeString​(java.lang.String s)
      Decodes a string from Base64 format
      static char[] encode​(byte[] in)
      Encodes a byte array into Base64 format.
      static char[] encode​(byte[] in, int iLen)
      Encodes a byte array into Base64 format.
      static java.lang.String encodeBytes​(byte[] in)
      Encodes a byte array into Base64 format.
      static java.lang.String encodeFile​(java.lang.String filename)
      Encodes a file into a Base64 format string
      static java.lang.String encodeString​(java.lang.String s)
      Encodes a string into Base64 format.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • encodeString

        public static java.lang.String encodeString​(java.lang.String s)
        Encodes a string into Base64 format. No blanks or line breaks are inserted
        Parameters:
        s - A String to be encoded
        Returns:
        A String with the Base64 encoded data
      • encodeBytes

        public static java.lang.String encodeBytes​(byte[] in)
        Encodes a byte array into Base64 format. No blanks or line breaks are inserted
        Parameters:
        in - An array containing the data bytes to be encoded
        Returns:
        A String with the Base64 encoded data
      • encode

        public static char[] encode​(byte[] in)
        Encodes a byte array into Base64 format. No blanks or line breaks are inserted
        Parameters:
        in - An array containing the data bytes to be encoded
        Returns:
        A character array with the Base64 encoded data
      • encode

        public static char[] encode​(byte[] in,
                                    int iLen)
        Encodes a byte array into Base64 format. No blanks or line breaks are inserted
        Parameters:
        in - An array containing the data bytes to be encoded
        iLen - Number of bytes to process in in
        Returns:
        A character array with the Base64 encoded data
      • decodeString

        public static java.lang.String decodeString​(java.lang.String s)
        Decodes a string from Base64 format
        Parameters:
        s - A Base64 String to be decoded
        Returns:
        A String containing the decoded data
        Throws:
        java.lang.IllegalArgumentException - if the input is not valid Base64 encoded data
      • decode

        public static byte[] decode​(java.lang.String s)
        Decodes a byte array from Base64 format
        Parameters:
        s - A Base64 String to be decoded
        Returns:
        An array containing the decoded data bytes
        Throws:
        java.lang.IllegalArgumentException - if the input is not valid Base64 encoded data
      • decode

        public static byte[] decode​(char[] in)
        Decodes a byte array from Base64 format. No blanks or line breaks are
        allowed within the Base64 encoded data
        Parameters:
        in - A character array containing the Base64 encoded data
        Returns:
        An array containing the decoded data bytes
        Throws:
        java.lang.IllegalArgumentException - if the input is not valid Base64 encoded data
      • encodeFile

        public static java.lang.String encodeFile​(java.lang.String filename)
                                           throws java.lang.Exception
        Encodes a file into a Base64 format string
        Throws:
        java.lang.Exception
      • byteArrayToBase64

        public static java.lang.String byteArrayToBase64​(byte[] a)
        Translates the specified byte array into a Base64 string as per Preferences.put(byte[])
      • byteArrayToAltBase64

        public static java.lang.String byteArrayToAltBase64​(byte[] a)
        Translates the specified byte array into an "aternate representation"
        Base64 string. This non-standard variant uses an alphabet that does
        not contain the uppercase alphabetic characters, which makes it
        suitable for use in situations where case-folding occurs