Class Utility


  • public final class Utility
    extends Object
    • Constructor Detail

      • Utility

        public Utility()
    • Method Detail

      • hex

        public static String hex​(char ch)
        Convert a char to 4 hex uppercase digits. E.g., hex('a') => "0041".
      • hex

        public static String hex​(String s)
        Convert a string to comma-separated groups of 4 hex uppercase digits. E.g., hex('ab') => "0041,0042".
      • hex

        public static String hex​(StringBuffer s)
        Convert a string to comma-separated groups of 4 hex uppercase digits. E.g., hex('ab') => "0041,0042".
      • hex

        public static StringBuffer hex​(char ch,
                                       StringBuffer output)
        Convert a char to 4 hex uppercase digits. E.g., hex('a') => "0041". Append the output to the given StringBuffer.
      • hex

        public static StringBuffer hex​(int ch,
                                       int width,
                                       StringBuffer output)
        Convert a integer to size width hex uppercase digits. E.g., hex('a', 4, str) => "0041". Append the output to the given StringBuffer. If width is too small to fit, nothing will be appended to output.
      • hex

        public static String hex​(int ch,
                                 int width)
        Convert a integer to size width (minimum) hex uppercase digits. E.g., hex('a', 4, str) => "0041". If the integer requires more than width digits, more will be used.
      • appendNumber

        public static StringBuffer appendNumber​(StringBuffer result,
                                                int n)
        Append a number to the given StringBuffer in the radix 10 generating at least one digit.
      • appendNumber

        public static StringBuffer appendNumber​(StringBuffer result,
                                                int n,
                                                int radix,
                                                int minDigits)
                                         throws IllegalArgumentException
        Append a number to the given StringBuffer in the given radix. Standard digits '0'-'9' are used and letters 'A'-'Z' for radices 11 through 36.
        Parameters:
        result - the digits of the number are appended here
        n - the number to be converted to digits; may be negative. If negative, a '-' is prepended to the digits.
        radix - a radix from 2 to 36 inclusive.
        minDigits - the minimum number of digits, not including any '-', to produce. Values less than 2 have no effect. One digit is always emitted regardless of this parameter.
        Returns:
        a reference to result
        Throws:
        IllegalArgumentException
      • hex

        public static String hex​(long i,
                                 int places)
        Supplies a zero-padded hex representation of an integer (without 0x)
      • hex

        public static String hex​(long ch)
      • hex

        public static StringBuffer hex​(String s,
                                       StringBuffer result)
        Convert a string to comma-separated groups of 4 hex uppercase digits. E.g., hex('ab') => "0041,0042". Append the output to the given StringBuffer.