java.lang.Object
io.github.palexdev.materialfx.utils.StringUtils
Utils class for
Strings.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsAll(String str, String split, String... words) Checks if the given string contains all the specifies words.static booleancontainsAny(String str, String split, String... words) Checks if the given string contains at least one of the given words.static booleancontainsIgnoreCase(CharSequence str, CharSequence searchStr) Checks if a CharSequence contains a search CharSequence irrespective of case, handlingnull.static Stringdifference(String str1, String str2) Finds the difference between twoStrings.static booleanendsWithIgnoreCase(String str, String suffix) Checks if the given string ends with the given prefix, ignores case.static intindexOfDifference(CharSequence cs1, CharSequence cs2) Finds the index at which twoCharSequencesdiffer.static StringrandAlphabetic(int length) Generates a random alphabetic string of given lengthstatic StringrandAlphanumeric(int length) Generates a random alphanumeric string of given lengthstatic StringreplaceIndex(String string, int startIndex, int endIndex, String replacement) static StringreplaceLast(String string, String substring, String replacement) Replaces the last occurrence of the given string with a new string.static booleanstartsWithIgnoreCase(String str, String prefix) Checks if thee given string starts with the specifies prefix, ignores case.static StringtimeToHumanReadable(long elapsedSeconds) A useful method to convert a given elapsed time in seconds to a String.static StringtitleCaseWord(String str)
-
Field Details
-
EMPTY
- See Also:
-
INDEX_NOT_FOUND
public static final int INDEX_NOT_FOUND- See Also:
-
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
difference
Finds the difference between twoStrings.- Parameters:
str1- The first Stringstr2- The second String- Returns:
- the difference between the two given strings
-
indexOfDifference
Finds the index at which twoCharSequencesdiffer.- Parameters:
cs1- The first sequencecs2- The second sequence
-
replaceLast
Replaces the last occurrence of the given string with a new string.- Parameters:
string- The string to modifysubstring- The last occurrence to findreplacement- The replacement- Returns:
- The modified string
-
replaceIndex
-
titleCaseWord
-
containsIgnoreCase
Checks if a CharSequence contains a search CharSequence irrespective of case, handling
null. Case-insensitivity is defined as byString.equalsIgnoreCase(String).A
nullCharSequence will returnfalse. -
startsWithIgnoreCase
Checks if thee given string starts with the specifies prefix, ignores case. -
endsWithIgnoreCase
Checks if the given string ends with the given prefix, ignores case. -
containsAny
Checks if the given string contains at least one of the given words.- Parameters:
split- this is the character that will split the input string, seeString.split(String)
-
containsAll
Checks if the given string contains all the specifies words.- Parameters:
split- this is the character that will split the input string, seeString.split(String)
-
timeToHumanReadable
A useful method to convert a given elapsed time in seconds to a String.- "Just now" if elapsed is less than 60 seconds
- minutes + " minutes ago" if the elapsed seconds is greater than 60 seconds
- hours + " minutes ago" if the elapsed minutes are greater than 60 minutes
- days + " days ago" if the elapsed hours are greater than 24
-
randAlphabetic
Generates a random alphabetic string of given length -
randAlphanumeric
Generates a random alphanumeric string of given length
-