Class StringUtil


  • public class StringUtil
    extends Object
    • Method Detail

      • repeat

        public static String repeat​(String s,
                                    int n)
        Concatenates string s n times.
        Parameters:
        s - string to repeat
        n - number of repetitions
        Returns:
        a string resulting from n repetitions of s, or null if n <= 0
      • formatLeft

        public static String formatLeft​(String s,
                                        String mask)
        Inserts a string s left-aligned into a mask, without truncation.

        Examples:
        formatLeft("abc", "123456") -> "abc456"
        formatLeft("abcdef", "123") -> "abcdef"
        Parameters:
        s -
        mask -
        Returns:
        s left-aligned in mask
      • formatRight

        public static String formatRight​(String s,
                                         String mask)
        Inserts a string s right-aligned into a mask, without truncation.

        Examples:
        formatRight("abc", "123456") -> "123abc"
        formatRight("abcdef", "123") -> "abcdef"
        Parameters:
        s -
        mask -
        Returns:
        s right-aligned in mask