public final class Strings extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
abbreviate(String str,
int offset,
int maxWidth) |
static String |
abbreviateFqClassName(String fqcn) |
static String |
abbreviateMiddle(String string,
int maxLength) |
static String |
getDomain(String url) |
static String |
getParent(String path) |
static String |
strip(String str,
String stripChars)
Strips any of a set of characters from the start and end of a String.
|
static String |
stripEnd(String str,
String stripChars)
Strips any of a set of characters from the end of a String.
|
static String |
stripStart(String str,
String stripChars)
Strips any of a set of characters from the start of a String.
|
static String |
substringAfterLast(String str,
String separator) |
public static String strip(String str, String stripChars)
Strips any of a set of characters from the start and end of a String.
This is similar to String.trim() but allows the characters
to be stripped to be controlled.
A null input String returns null.
An empty string ("") input returns the empty string.
StringUtils.strip(null, *) = null
StringUtils.strip("", *) = ""
StringUtils.strip("abc", null) = "abc"
StringUtils.strip(" abc", null) = "abc"
StringUtils.strip("abc ", null) = "abc"
StringUtils.strip(" abc ", null) = "abc"
StringUtils.strip(" abcyx", "xyz") = " abc"
str - the String to remove characters from, may be nullstripChars - the characters to remove, null treated as whitespacenull if null String inputpublic static String stripStart(String str, String stripChars)
Strips any of a set of characters from the start of a String.
A null input String returns null.
An empty string ("") input returns the empty string.
If the stripChars String is null, whitespace is
stripped as defined by Character.isWhitespace(char).
StringUtils.stripStart(null, *) = null
StringUtils.stripStart("", *) = ""
StringUtils.stripStart("abc", "") = "abc"
StringUtils.stripStart("abc", null) = "abc"
StringUtils.stripStart(" abc", null) = "abc"
StringUtils.stripStart("abc ", null) = "abc "
StringUtils.stripStart(" abc ", null) = "abc "
StringUtils.stripStart("yxabc ", "xyz") = "abc "
str - the String to remove characters from, may be nullstripChars - the characters to remove, null treated as whitespacenull if null String inputpublic static String stripEnd(String str, String stripChars)
Strips any of a set of characters from the end of a String.
A null input String returns null.
An empty string ("") input returns the empty string.
If the stripChars String is null, whitespace is
stripped as defined by Character.isWhitespace(char).
StringUtils.stripEnd(null, *) = null
StringUtils.stripEnd("", *) = ""
StringUtils.stripEnd("abc", "") = "abc"
StringUtils.stripEnd("abc", null) = "abc"
StringUtils.stripEnd(" abc", null) = " abc"
StringUtils.stripEnd("abc ", null) = "abc"
StringUtils.stripEnd(" abc ", null) = " abc"
StringUtils.stripEnd(" abcyx", "xyz") = " abc"
StringUtils.stripEnd("120.00", ".0") = "12"
str - the String to remove characters from, may be nullstripChars - the set of characters to remove, null treated as whitespacenull if null String inputCopyright © 2018 JBoss, a division of Red Hat. All rights reserved.