Class StringTools


  • public class StringTools
    extends Object
    StringTools
    • Constructor Detail

      • StringTools

        public StringTools()
    • Method Detail

      • isEmpty

        public static boolean isEmpty​(String text)
        Test if the given text is null or an empty string
      • isNotEmpty

        public static boolean isNotEmpty​(String text)
        Test if the given text is not null and not an empty string
      • rightPad

        public static String rightPad​(String value,
                                      int size,
                                      char padChar)
        Right pad the given string
      • startsWith

        public static boolean startsWith​(String text,
                                         String prefix,
                                         int offset,
                                         boolean ignoreCase)
        Case-aware version of startsWith()
      • startsWithIgnoreCase

        public static boolean startsWithIgnoreCase​(String text,
                                                   String prefix,
                                                   int offset)
        Case-insensitive version of startsWith()
      • indexOf

        public static int indexOf​(String text,
                                  String needle,
                                  int fromIndex,
                                  boolean ignoreCase)
        Case-aware version of startsWith()
      • indexOfIgnoreCase

        public static int indexOfIgnoreCase​(String text,
                                            String needle,
                                            int fromIndex)
        Case-insensitive version of indexOf()
      • matches

        public static boolean matches​(String text,
                                      String pattern)
        Check if the given text matches a pattern
      • matchesIgnoreCase

        public static boolean matchesIgnoreCase​(String text,
                                                String pattern)
        Check if the given text matches a pattern
      • matches

        protected static boolean matches​(String text,
                                         String pattern,
                                         boolean ignoreCase)
        Check if the given text matches a pattern
      • capitalize

        public static String capitalize​(String text)
        Capitalize the given string (null safe)
        Parameters:
        text - String to capitalize
        Returns:
        the capitalized string
      • split

        public static String[] split​(String str,
                                     char separatorChar)
      • formatSize

        public static String formatSize​(long size)
        Format the given size
      • asHex

        public static String asHex​(byte[] data)