Class StringUtil

java.lang.Object
com.mckoi.util.StringUtil

public class StringUtil extends Object
Various String utilities.
Author:
Tobias Downer
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • find

      public static int find(String source, String find)
      Finds the index of the given string in the source string.

      Returns:
      -1 if the 'find' string could not be found.
    • explode

      public static List explode(String source, String deliminator)
      Performs an 'explode' operation on the given source string. This algorithm finds all instances of the deliminator string, and returns an array of sub-strings of between the deliminator. For example, explode("10:30:40:55", ":") = ({"10", "30", "40", "55"})
    • implode

      public static String implode(List list, String deliminator)
      This is the inverse of 'explode'. It forms a string by concatinating each string in the list and seperating each with a deliminator string. For example, implode(({"1", "150", "500"}), ",") = "1,150,500"
    • searchAndReplace

      public static String searchAndReplace(String source, String search, String replace)
      Searches for various instances of the 'search' string and replaces them with the 'replace' string.