public final class StringUtil extends Object
| Constructor and Description |
|---|
StringUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
charsToString(Set<Character> set) |
static String |
chomp(String str)
chomp single newline combination from end of string
Copied from Apache Commons StrinUtil (http://www.apache.org/licenses/LICENSE-2.0)
|
static boolean |
containsWildcards(String string)
Detects if a given string contains shell wildcard characters (e.g.
|
static int |
getNumOccurrences(String str,
String substr)
Returns a number of occurrences of a given substring in a given string.
|
static String |
getQualifier(String st)
Return any qualifiers (quotation marks etc.) around text in a given string.
|
static String |
getString(int length,
char c)
Returns a new string padded with a given character repeated given times.
|
static boolean |
hasQualifiers(String st)
Test if there are qualifiers (quotation marks etc.) around text in a given string.
|
static boolean |
isWhitespace(String str)
Checks if a given string contains only whitespace characters.
|
static float |
LcsEditDistance(CharSequence seq1,
CharSequence seq2)
Longest Common Subsequence algorithm on
CharSequences. |
static boolean |
matchesWildcard(String string,
String pattern)
Detects if a given string matches a given pattern (not necessarily a regex), possibly containing wildcards
|
static boolean |
matchesWildcard(String string,
String pattern,
boolean filenameMode)
Detects if a given string matches a given pattern (not necessarily a regex), possibly containing wildcards
|
static String |
mirrorString(String str)
Returns the reversed version of a given string, e.g.
|
static String |
normalizeLineBreaks(String string)
Converts line breaks in a given string to the Unix standard (\n).
|
static String |
normalizeWildcards(String string)
Converts shell wildcards (e.g.
|
static String |
padString(String string,
int startPos,
int endPos,
char padder)
Pads a range of a given string with a given character.
|
static String |
readString(File path) |
static String |
readString(URL url) |
static String |
removeAnyQualifiers(String st)
Removes quotation marks (double or single) around text in a given string.
|
static String |
removeQualifiers(String st)
Removes quotation marks around text in a given string.
|
static String |
removeQualifiers(String st,
String qualifier)
Removes qualifiers (quotation marks etc.) around text in a given string.
|
static String |
removeQualifiers(String st,
String startQualifier,
String endQualifier)
Removes qualifiers (quotation marks etc.) around text in a given string.
|
static String |
removeWhiteSpace(String s)
Fast version of removeWhiteSpace vs regex version
|
static String |
repeatChar(char c,
int rep)
Build a string made of the given character for the specfied number
|
static String[] |
split(String string,
String delimRegex) |
static String[] |
split(String string,
String delimRegex,
int group) |
static String |
substring(String string,
int start,
int end) |
static String |
titleCase(String st)
Returns a title-case representation of a given string.
|
static void |
writeString(String str,
File path) |
static void |
writeString(String str,
OutputStream os) |
public static float LcsEditDistance(CharSequence seq1, CharSequence seq2)
CharSequences.seq1 - CharSequence oneseq2 - CharSequence twopublic static String titleCase(String st)
st - the give string.public static String removeQualifiers(String st, String startQualifier, String endQualifier)
st - the given string.startQualifier - the qualifier to be removed before the given string.endQualifier - the qualifier to be removed after the given string.public static String getQualifier(String st)
st - the given string.public static boolean hasQualifiers(String st)
st - the given string.public static String removeQualifiers(String st, String qualifier)
st - the given string.qualifier - the qualifier to be removed before and after text in the string.public static String removeAnyQualifiers(String st)
st - the given string.public static String removeQualifiers(String st)
st - the given string.public static String normalizeLineBreaks(String string)
string - the given string.public static String normalizeWildcards(String string)
string - the given string.public static boolean containsWildcards(String string)
string - the given string.public static boolean matchesWildcard(String string, String pattern, boolean filenameMode)
string - the given string (no-wildcards)pattern - the pattern containing wildcards to match againstfilenameMode - indicates if the given string should be considered a file namepublic static boolean matchesWildcard(String string, String pattern)
string - the given string (no-wildcards)pattern - the pattern containing wildcards to match againstpublic static int getNumOccurrences(String str, String substr)
str - the given string.substr - the given substring being sought.public static boolean isWhitespace(String str)
str - the given stringpublic static String getString(int length, char c)
length - length of the new stringc - the character to pad the stringpublic static String padString(String string, int startPos, int endPos, char padder)
string - the given stringstartPos - start position of the pad range (including)endPos - end position of the pad range (excluding)padder - the character to pad the range withpublic static String mirrorString(String str)
str - The given stringpublic static void writeString(String str, OutputStream os)
public static String removeWhiteSpace(String s)
s - string with whitespacepublic static String chomp(String str)
str - the string to chop.public static String repeatChar(char c, int rep)
c - character to repeatrep - the number of repeatCopyright © 2021. All rights reserved.