Package com.liferay.petra.string
Class StringUtil
java.lang.Object
com.liferay.petra.string.StringUtil
The String utility class.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanequalsIgnoreCase(char c1, char c2) static booleanequalsIgnoreCase(String s1, String s2) Returnstrueif the strings are equal, ignoring case.static Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic <T> Stringmerge(Collection<T> collection, String delimiter) static <T> Stringmerge(Collection<T> collection, Function<T, String> toStringFunction, String delimiter) static <T,L extends List<T> & RandomAccess>
Stringstatic <T,L extends List<T> & RandomAccess>
Stringstatic <T> Stringstatic <T> Stringstatic Stringread(InputStream inputStream) static Stringread(ClassLoader classLoader, String name) static Stringread(ClassLoader classLoader, String name, boolean all) static StringReplaces all occurrences of the character with the new character.static StringReplaces all occurrences of the string with the new string.static StringReplaces all occurrences of the string with the new string, starting from the specified index.
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
equalsIgnoreCase
public static boolean equalsIgnoreCase(char c1, char c2) -
equalsIgnoreCase
Returnstrueif the strings are equal, ignoring case.- Parameters:
s1- the first string to compares2- the second string to compare- Returns:
trueif the strings are equal, ignoring case;falseotherwise
-
merge
-
merge
-
merge
-
merge
public static <T> String merge(Collection<T> collection, Function<T, String> toStringFunction, String delimiter) -
merge
-
merge
-
merge
-
merge
-
merge
-
merge
-
merge
-
merge
-
merge
-
merge
-
merge
-
read
- Throws:
IOException
-
read
- Throws:
IOException
-
read
- Throws:
IOException
-
replace
Replaces all occurrences of the character with the new character.- Parameters:
s- the original stringoldSub- the character to be searched for and replaced in the original stringnewSub- the character with which to replace theoldSubcharacter- Returns:
- a string representing the original string with all occurrences of
the
oldSubcharacter replaced with thenewSubcharacter, ornullif the original string isnull
-
replace
Replaces all occurrences of the string with the new string.- Parameters:
s- the original stringoldSub- the string to be searched for and replaced in the original stringnewSub- the string with which to replace theoldSubstring- Returns:
- a string representing the original string with all occurrences of
the
oldSubstring replaced with the stringnewSub, ornullif the original string isnull
-
replace
Replaces all occurrences of the string with the new string, starting from the specified index.- Parameters:
s- the original stringoldSub- the string to be searched for and replaced in the original stringnewSub- the string with which to replace theoldSubstringfromIndex- the index of the original string from which to begin searching- Returns:
- a string representing the original string with all occurrences of
the
oldSubstring occurring after the specified index replaced with the stringnewSub, ornullif the original string isnull
-
split
-
split
-