Package com.mckoi.util
Class StringUtil
- java.lang.Object
-
- com.mckoi.util.StringUtil
-
public class StringUtil extends java.lang.Object
Various String utilities.- Author:
- Tobias Downer
-
-
Constructor Summary
Constructors Constructor Description StringUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List
explode(java.lang.String source, java.lang.String deliminator)
Performs an 'explode' operation on the given source string.static int
find(java.lang.String source, java.lang.String find)
Finds the index of the given string in the source string.static java.lang.String
implode(java.util.List list, java.lang.String deliminator)
This is the inverse of 'explode'.static java.lang.String
searchAndReplace(java.lang.String source, java.lang.String search, java.lang.String replace)
Searches for various instances of the 'search' string and replaces them with the 'replace' string.
-
-
-
Method Detail
-
find
public static int find(java.lang.String source, java.lang.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 java.util.List explode(java.lang.String source, java.lang.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 java.lang.String implode(java.util.List list, java.lang.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 java.lang.String searchAndReplace(java.lang.String source, java.lang.String search, java.lang.String replace)
Searches for various instances of the 'search' string and replaces them with the 'replace' string.
-
-