Class StringUtil

java.lang.Object
org.mbari.jcommons.util.StringUtil

public class StringUtil extends Object
  • Method Details

    • getToken

      public static final String getToken(String str, int tokenNumber, String delim)
      Return the token specified by position in a string using the specified delimiter. For example,
      String str = "Mary;had;a;little;lamb."; String little = StringUtilities.getToken(str, 4, ";"); // little = "little"
      Parameters:
      str - The string to parse
      tokenNumber - The (ones-based) index of the token to be returned
      delim - The token delimiter
      Returns:
      String From position specifed
    • getToken

      public static final String getToken(String str, int tokenNumber)
      Return the token specified by position in a string using white space delimiters (\t\r\n\f and space). For example,
      String str = "Mary had a little lamb."; String little = StringUtilities.getToken(str, 4); // little = "little"
      Parameters:
      str - The string to parse
      tokenNumber - The (ones-based) index of the token to be returned
      Returns:
      String from position specified
    • order

      public static final String[] order(String[] values, int[] order)
      Useful method for ordering a 1-D array based on an array of indices
      Parameters:
      values - A 1-D array of data to be sorted based on an array of indices
      order - A 1-D array of indices specifying the ordering of the data.
    • repeat

      public static final String repeat(String s, int i)
      Repeat a string. Analagous to pythons ability to do "AB" * 2 = "ABAB". For example: StringUtilities.repeat("AB", 2) = "ABAB"
      Parameters:
      s - The string to repeat
      i - The number of times to repeat the string
    • isBlank

      public static boolean isBlank(CharSequence cs)
    • containsOrderedChars

      public static boolean containsOrderedChars(String chars, String text)