Class Strings


  • public class Strings
    extends Object
    Various String related utility methods, written mostly to avoid generation of new String objects (e.g. via splitting Strings etc).
    • Constructor Detail

      • Strings

        public Strings()
    • Method Detail

      • stripTrailing

        public static String stripTrailing​(String pattern,
                                           char c)
        Strip trailing characters
        Parameters:
        pattern - non null
        c - character to remove
        Returns:
        new string with all trailing characters removed
      • stripTrailingWhitespace

        public static String stripTrailingWhitespace​(String pattern)
        Strip trailing whitespace characters
        Parameters:
        pattern - non null
        Returns:
        new string with all trailing whitespace removed
      • isDirectoryPattern

        public static boolean isDirectoryPattern​(String pattern)
        Check if pattern is a directory pattern ending with a path separator
        Parameters:
        pattern - non null
        Returns:
        true if the last character, which is not whitespace, is a path separator
      • split

        public static List<String> split​(String pattern,
                                         char slash)
        Splits given string to substrings by given separator
        Parameters:
        pattern - non null
        slash - separator char
        Returns:
        list of substrings