Class StringTools


  • public class StringTools
    extends Object
    StringTools is a utility class for simple static operations related to strings.
    • Method Detail

      • length

        public static int length​(String str)
        Count the number of code points in a String. This is equivalent to calling codePointCount on the entire String (beginIndex=0 and endIndex=string.length()).
        Parameters:
        str - the String to count length on
        Returns:
        returns the number of code points in the entire String
      • fill

        public static String fill​(char c,
                                  int length)
        Fill a String with a single character.
        Parameters:
        c - the character to fill with
        length - the length of the resulting String
        Returns:
        returns a String filled with character c
      • fill

        public static String fill​(String s,
                                  int length)
        Fill a String with copies of another String.
        Parameters:
        s - the String to fill with
        length - the length of the resulting String
        Returns:
        returns a String filled with String s
        Throws:
        IllegalArgumentException - if the string is empty