Class StringUtils


  • public final class StringUtils
    extends Object
    Useful methods for working with Strings.
    Author:
    Curtis Rueden, Chris Allan, Melissa Linkert, Richard Domander (Royal Veterinary College, London)
    • Method Detail

      • splitUnquoted

        public static String[] splitUnquoted​(String s,
                                             String separator)
        Splits a string only at separators outside of quotation marks ("). Does not handle escaped quotes.
      • sanitizeDouble

        public static String sanitizeDouble​(String value)
        Normalizes the decimal separator for the user's locale.
      • stripNulls

        public static String stripNulls​(String toStrip)
        Removes null bytes from a string.
      • samePrefix

        public static boolean samePrefix​(String s1,
                                         String s2)
        Checks if two filenames have the same prefix.
      • sanitize

        public static String sanitize​(String s)
        Removes unprintable characters from the given string.
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(String s)
      • padEnd

        public static String padEnd​(String s,
                                    int length,
                                    char padChar)
        Adds characters to the end of the String to make it the given length
        Parameters:
        s - the original string
        length - the length of the string with padding
        padChar - the character added to the end
        Returns:
        the end padded String. Null if s is null, s if no padding is not necessary
      • padStart

        public static String padStart​(String s,
                                      int length,
                                      char padChar)
        Adds characters to the start of the String to make it the given length
        Parameters:
        s - the original string
        length - the length of the string with padding
        padChar - the character added to the start
        Returns:
        the start padded String. Null if s is null, s if no padding is not necessary