public final class Strings extends Object
| 构造器和说明 |
|---|
Strings() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
concatPath(String prefixPath,
String suffixPath)
拼接两个路径,以“/”开头,不以“/”结尾
e.g.: concatPath("/a", "/b/c") -> /a/b/c
|
static String |
concatSqlLike(String str) |
static boolean |
isMatch(String s,
String p)
'?'
|
static String |
of(byte[] bytes,
Charset charset) |
static String |
requireNonBlank(String str) |
static String |
substringAfterLast(String str,
String separator)
substringAfterLast(null, "
|
static String |
toCamelCaseFormat(String separatedFormat,
char separator)
带分隔符名字转驼峰,如下划线转换为驼峰:CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, underscoreName);
1、LOWER_HYPHEN -> 连字符的变量命名规范如lower-hyphen
2、LOWER_UNDERSCORE -> c++变量命名规范如lower_underscore
3、LOWER_CAMEL -> java变量命名规范如lowerCamel
4、UPPER_CAMEL -> java和c++类的命名规范如UpperCamel
5、UPPER_UNDERSCORE -> java和c++常量的命名规范如UPPER_UNDERSCORE
|
static String |
toSeparatedFormat(String camelcaseFormat,
char separator)
驼峰转为带分隔符名字,如驼峰转换为下划线:CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, camelCaseName);
|
static String |
trimPath(String path)
Returns trim path.
|
static String |
withSuffix(String str,
String suffix) |
public static boolean isMatch(String s, String p)
'?' Matches any single character.
'*' Matches any sequence of characters (including the empty sequence).
isMatch("aa","a") = false
isMatch("aa","aa") = true
isMatch("aaa","aa") = false
isMatch("aa", "*") = true
isMatch("aa", "a*") = true
isMatch("ab", "?*") = true
isMatch("aab", "c*a*b") = false
s - the textp - the wildcard patterntrue if the string match patternpublic static String toSeparatedFormat(String camelcaseFormat, char separator)
camelcaseFormat - the camelcase formatseparator - the separator characterCaseFormat.to(CaseFormat, String)public static String toCamelCaseFormat(String separatedFormat, char separator)
1、LOWER_HYPHEN -> 连字符的变量命名规范如lower-hyphen 2、LOWER_UNDERSCORE -> c++变量命名规范如lower_underscore 3、LOWER_CAMEL -> java变量命名规范如lowerCamel 4、UPPER_CAMEL -> java和c++类的命名规范如UpperCamel 5、UPPER_UNDERSCORE -> java和c++常量的命名规范如UPPER_UNDERSCORE
separatedFormat - the separated formatseparator - the separator characterCaseFormat.to(CaseFormat, String)public static String trimPath(String path)
trimPath("test///") = "/test"
trimPath("test/abc///") = "/test/abc"
trimPath(" /test/abc/// ") = "/test/abc"
trimPath(" / // /// ") = "/"
trimPath(" /test/abc/ / / ") = "/test/abc"
path - the pathpublic static String concatPath(String prefixPath, String suffixPath)
e.g.: concatPath("/a", "/b/c") -> /a/b/c
prefixPath - the prefix pathsuffixPath - the suffix pathpublic static String substringAfterLast(String str, String separator)
substringAfterLast(null, ".") = null
substringAfterLast("", ".") = ""
substringAfterLast("abc", ".") = "abc"
substringAfterLast("abc.def", ".") = "def"
substringAfterLast(".abc", ".") = "abc"
substringAfterLast("abc.", ".") = ""
str - the stringseparator - the separatorCopyright © 2024. All rights reserved.