- 浏览: 38048 次
- 性别:
- 来自: 北京
文章分类
最新评论
36.public static boolean containsNone(String str, char[] invalidChars)
判断是否字符串str不包含字符数组invalidChars中的字符,如果含有则返回false。
举例(*表示任意):
StringUtils.containsNone(null, *) = true
StringUtils.containsNone(*, []) = true
StringUtils.containsNone("", *) = true
StringUtils.containsNone("ab", []) = true
StringUtils.containsNone("b", ['a','f',' ']) = true
StringUtils.containsNone("bcd", ['a','f',' ']) = true
StringUtils.containsNone("abc", ['a','f',' ']) = false
StringUtils.containsNone(" ", ['a','f',' ']) = false
37.public static boolean containsNone(String str, String invalidChars)
判断是否字符串str不包含字符串invalidChars中的字符,如果含有则返回false。
举例(*表示任意):
StringUtils.containsNone(null, *) = true
StringUtils.containsNone(*, null) = true
StringUtils.containsNone("", *) = true
StringUtils.containsNone("ab", "") = true
StringUtils.containsNone("b", "af ") = true
StringUtils.containsNone("bcd", "af ") = true
StringUtils.containsNone("abc", "af ") = false
StringUtils.containsNone(" ", "af ") = false
38.public static int indexOfAny(String str, String[] searchStrs)
找出字符串数组searchStrs中的字符串第一次出现在字符串str中的位置。
如果数组中没有字符串在str中,则返回-1
如果数组为null或长度为0,则返回-1
举例(*表示任意):
StringUtils.indexOfAny(null, *) = -1
StringUtils.indexOfAny(*, null) = -1
StringUtils.indexOfAny(*, []) = -1
StringUtils.indexOfAny("", [""]) = 0
StringUtils.indexOfAny("bbeegg", ["as","df","yy"]) = -1
StringUtils.indexOfAny("asdfgh", ["as","df","yy"]) = 0
StringUtils.indexOfAny("dfasgh", ["as","df","yy"]) = 0
StringUtils.indexOfAny("ghasdf", ["as","df","yy"]) = 2
39.public static int lastIndexOfAny(String str, String[] searchStrs)
找出字符串数组searchStrs中的字符串最后一次出现在字符串str中的位置。
如果数组中没有字符串在str中,则返回-1
如果数组为null或长度为0,则返回-1
举例(*表示任意):
StringUtils.lastIndexOfAny(null, *) = -1
StringUtils.lastIndexOfAny(*, null) = -1
StringUtils.lastIndexOfAny(*, []) = -1
StringUtils.lastIndexOfAny("", [""]) = 0
StringUtils.lastIndexOfAny("bbeegg", ["as","df","yy"]) = -1
StringUtils.lastIndexOfAny("asdfgh", ["as","df","yy"]) = 2
StringUtils.lastIndexOfAny("dfghjk", ["as","df","yy"]) = 0
StringUtils.lastIndexOfAny("ghasdf", ["as","df","yy"]) = 4
StringUtils.lastIndexOfAny("ghasdf", ["as","df",""]) = 6
40.public static String substring(String str, int start)
得到字符串str的子串。
如果start小于0,位置是从后往前数的第|start|个
如果str为null或"",则返回它本身
举例(*表示任意):
StringUtils.substring(null, *) = null
StringUtils.substring("", *) = ""
StringUtils.substring("asdf", 0)) = "asdf"
StringUtils.substring("asdf", 1)) = "sdf"
StringUtils.substring("asdf", 3)) = "f"
StringUtils.substring("asdf",) = ""
StringUtils.substring("asdf", -1)) = "f"
StringUtils.substring("asdf", -3)) = "sdf"
StringUtils.substring("asdf", -8)) = "asdf"
41.public static String substring(String str, int start, int end)
得到字符串str的子串。
如果start小于0,位置是从后往前数的第|start|个,
如果end小于0,位置是从后往前数的第|end|个,
如果str为null或"",则返回它本身
举例(*表示任意):
StringUtils.substring(null, *, *) = null
StringUtils.substring("", * , *) = "";
StringUtils.substring("asdf", 0, 2) = "as"
StringUtils.substring("asdf", 0, -1) = "asd"
StringUtils.substring("asdf", 2, -1) = "d"
StringUtils.substring("asdf", 2, -2) = ""
StringUtils.substring("asdf", 3, 2) = ""
StringUtils.substring("asdf", 1, = "sdf"
StringUtils.substring("asdf", -1, -3) = ""
StringUtils.substring("asdf", -3, -1) = "sd"
StringUtils.substring("asdf", -8, 5) = "asdf"
42.public static String left(String str, int len)
得到字符串str从左边数len长度的子串。
如果str为null或为"",则返回它本身
如果len小于0,则返回""
举例(*表示任意):
StringUtils.left(null, *) = null
StringUtils.left(*, -ve) = ""
StringUtils.left("", *) = ""
StringUtils.left("asdf", 0) = ""
StringUtils.left("asdf", 2) = "as"
StringUtils.left("asdf", = "asdf"
43.public static String right(String str, int len)
得到字符串str从右边数len长度的子串。
如果str为null或为"",则返回它本身
如果len小于0,则返回""
举例(*表示任意):
StringUtils.right(null, *) = null
StringUtils.right(*, -ve) = ""
StringUtils.right("", *) = ""
StringUtils.right("asdf", 0) = ""
StringUtils.right("asdf", 2) = "df"
StringUtils.right("asdf", = "asdf"
44.public static String mid(String str, int pos, int len)
得到字符串str从pos开始len长度的子串。
如果str为null或为"",则返回它本身
如果len小于0或pos大于srt的长度,则返回""
如果pos小于0,则pos设为0
举例(*表示任意):
StringUtils.mid(null, *, *) = null
StringUtils.mid("", *, *) = ""
StringUtils.mid(*, *, -ve) = ""
StringUtils.mid("asdf", 0, 4)) = "asdf"
StringUtils.mid("asdf", 2, 2)) = "df"
StringUtils.mid("asdf", 2, 5)) = "df"
StringUtils.mid("asdf", -2, 1)) = "a"
StringUtils.mid("asdf", 0, -1)) = ""
45.public static String substringBefore(String str, String separator)
得到字符串str的在字符串separator出现前的字串,且separator不包括在内。
如果str为null或为"",则返回它本身
如果separator为null,则返回str本身
举例(*表示任意):
StringUtils.substringBefore(null, *) = null
StringUtils.substringBefore("", *) = ""
StringUtils.substringBefore("asdfg", null)) = "asdfg"
StringUtils.substringBefore("asdfg", "a")) = ""
StringUtils.substringBefore("asdfg", "sd")) = "a"
StringUtils.substringBefore("asdfsag", "sa")) = "asdf"
StringUtils.substringBefore("asdfg", "h")) = "asdfg"
StringUtils.substringBefore("asdfg", "")) = ""
StringUtils.substringBefore("asdfg", "dfgh")) = "asdfg"
StringUtils.substringBefore("asdfg", "dfg")) = "as"
StringUtils.substringBefore("abbbabbba", "bb")) = "a"
46.public static String substringAfter(String str, String separator)
得到字符串str的在字符串separator出现后的字串,且separator不包括在内。
如果str为null或为"",则返回它本身
如果separator为null,则返回""
举例(*表示任意):
StringUtils.substringAfter(null, *) = null
StringUtils.substringAfter("", *) = ""
StringUtils.substringAfter(*, null) = ""
StringUtils.substringAfter("asdfg", "a")) = "sdfg"
StringUtils.substringAfter("asdfg", "sd")) = "fg"
StringUtils.substringAfter("asdfsag", "sa")) = "g"
StringUtils.substringAfter("asdfg", "h")) = ""
StringUtils.substringAfter("asdfg", "")) = "asdfg"
StringUtils.substringAfter("asdfg", "dfgh")) = ""
StringUtils.substringAfter("asdfg", "dfg")) = ""
StringUtils.substringAfter("abbbabbba", "bb"))= "babbba"
47.public static String substringBeforeLast(String str, String separator)
和45类似,得到字符串str的在字符串separator最后一次出现前的字串。
这里不再举例。
48.public static String substringAfterLast(String str, String separator)
和46类似,得到字符串str的在字符串separator最后一次出现后的字串。
这里不再举例。
49.public static String substringBetween(String str, String tag)
得到str中的在两个字符串tag中间的字符串,即str中的tag所夹的串。
如果str为null或tag为null,返回null
举例(*表示任意):
StringUtils.substringBetween(null, *) = null
StringUtils.substringBetween(*, null) = null
StringUtils.substringBetween("", "") = ""
StringUtils.substringBetween("", "a")) = null
StringUtils.substringBetween("asdfdf", "df")) = ""
StringUtils.substringBetween("asdfas", "as")) = "df"
StringUtils.substringBetween("dfasdfasdfas", "df")) = "as"
StringUtils.substringBetween("dfasdfasdfas", "as")) = "df"
StringUtils.substringBetween("dfasdfasgdf", "df")) = "as"
50.public static String substringBetween(String str, String open, String close)
得到str中的在两个字符串open和close中间的字符串,即open和close所夹的串。
如果str为null或open为null或close为null,返回null
举例(*表示任意):
StringUtils.substringBetween(null, *, *) = null
StringUtils.substringBetween(*, null, *) = null
StringUtils.substringBetween(*, *, null) = null
StringUtils.substringBetween("", "", "") = ""
StringUtils.substringBetween("", "", "]") = null
StringUtils.substringBetween("", "[", "]") = null
StringUtils.substringBetween("[]", "[","]")) = ""
StringUtils.substringBetween("a[sd]f", "[","]")) = "sd"
StringUtils.substringBetween("a[sd]f[gh]", "[","]")) = "sd"
StringUtils.substringBetween("a[sd]f", "]","[")) = null
StringUtils.substringBetween("a[sd]f", "","")) = ""
51.public static String[] substringsBetween(String str, String open, String close)
得到str中的在两个字符串open和close中间的字符串,即open和close所夹的串,
把所有符合的结果放在数组中返回。
和50类似,但是返回了所有的结果(50只返回了第一个匹配的结果)。
这里不再举例。
52.public static String[] split(String str)
把字符串拆分成一个字符串数组,用空白符(whitespace)作为分隔符。
Whitespace是这样定义的 {@link Character#isWhitespace(char)}
如果字符串为null,返回null
如果字符串为"",返回空数组{}
举例(*表示任意):
StringUtils.split(null) = null
StringUtils.split("") = {}
StringUtils.split("as df yy")) = {"as","df","yy"}
StringUtils.split(" as df yy ")) = {"as","df","yy"}
StringUtils.split("as\ndf\ryy")) = {"as","df","yy"}
StringUtils.split("as\tdf\fyy")) = {"as","df","yy"}
StringUtils.split("as df \fyy")) = {"as","df","yy"}
StringUtils.split("as\t \r df \f \n yy")) = {"as","df","yy"}
StringUtils.split("as")) = {"as"}
StringUtils.split(" as ")) = {"as"}
53.public static String[] split(String str, char separatorChar)
把字符串拆分成一个字符串数组,用指定的字符separatorChar作为分隔符。
如果字符串为null,返回null
如果字符串为"",返回空数组{}
举例(*表示任意):
StringUtils.split(null, *) = null
StringUtils.split("", *) = {}
StringUtils.split("as df yy",' ')) = {"as","df","yy"}
StringUtils.split(" as df yy ",' ')) = {"as","df","yy"}
StringUtils.split("asodfoyy",'o')) = {"as","df","yy"}
StringUtils.split("as.df.yy",'.')) = {"as","df","yy"}
StringUtils.split("as\ndf\nyy",'\n'))= {"as","df","yy"}
StringUtils.split("as",' ')) = {"as"}
StringUtils.split(" as ",' ')) = {"as"}
54.public static String[] split(String str, String separatorChars)
把字符串拆分成一个字符串数组,用指定的字符串separatorChars作为分隔符。
如果字符串str为null,返回null
如果字符串str为"",返回空数组{}
如果separatorChars为null,则默认为空白符
和53类似。
举例(*表示任意):
StringUtils.split("as \rdf \t yy",null)) = {"as","df","yy"}
StringUtils.split("as\ndf\fyy",null)) = {"as","df","yy"}
StringUtils.split("as","")) = {"as"}
55.public static String[] split(String str, String separatorChars, int max)
把字符串拆分成一个字符串数组,用指定的字符串separatorChars作为分隔符,
数组的最大长度为max。
如果字符串str为null,返回null
如果字符串str为"",返回空数组{}
如果separatorChars为null,则默认为空白符
如果max小于等于0,认为是没有限制
举例(*表示任意):
StringUtils.split(null, *, *) = null
StringUtils.split("", *, *) = {}
StringUtils.split("as df yy",null,0)) = {"as","df","yy"}
StringUtils.split("as df yy"," ",0)) = {"as","df","yy"}
StringUtils.split("as.df.yy",".",-1)) = {"as","df","yy"}
StringUtils.split("as.df.yy",".",4)) = {"as","df","yy"}
StringUtils.split("as-!-df-!-yy","-!-",0)) = {"as","df","yy"}
StringUtils.split("as.df.yy",".",2)) = {"as","df.yy"}
StringUtils.split("as","",0)) = {"as"}
StringUtils.split("as","",2)) = {"as"}
56.public static String[] splitByWholeSeparator(String str, String separator)
个人认为和54功能一样。区别有待发掘。
57.public static String[] splitByWholeSeparator( String str, String separator, int max )
个人认为和55功能一样。区别有待发掘。
58.public static String[] splitPreserveAllTokens(String str)
把字符串str拆分成一个数组,用空白符(whitespace)作为分隔符,保留所有的标识,
包括相邻分隔符产生的空的标识。它可作为StringTokenizer的一个替代。
Whitespace是这样定义的{@link Character#isWhitespace(char)}。
举例(*表示任意):
StringUtils.splitPreserveAllTokens(null)) = null
StringUtils.splitPreserveAllTokens("")) = {}
StringUtils.splitPreserveAllTokens("as df gh jk")) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as\ndf\rgh\fjk")) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as\tdf gh jk")) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as df gh")) = {"as","","df","gh"}
StringUtils.splitPreserveAllTokens(" as df ")) = {"","as","","","df","",""}
59.public static String[] splitPreserveAllTokens(String str, char separatorChar)
和58类似,只是分隔符为字符separatorChar。
举例(*表示任意):
StringUtils.splitPreserveAllTokens(null, *) = null
StringUtils.splitPreserveAllTokens("", *) = {}
StringUtils.splitPreserveAllTokens("as df gh jk",' ')) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as.df.gh.jk",'.')) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as..df.gh",'.')) = {"as","","df","gh"}
StringUtils.splitPreserveAllTokens(",as,,,df,,",',')) = {"","as","","","df","",""}
StringUtils.splitPreserveAllTokens("as.df.gh",',')) = {"as.df.gh"}
60.public static String[] splitPreserveAllTokens(String str, String separatorChars)
和59类似,只是分隔符为字符串separatorChars。
举例(*表示任意):
StringUtils.splitPreserveAllTokens(null, *) = null
StringUtils.splitPreserveAllTokens("", *) = {}
StringUtils.splitPreserveAllTokens("as df gh jk",null)) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as\ndf\rgh\fjk",null))= {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as df gh jk"," ")) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as.df.gh.jk",".")) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as..df.gh",".")) = {"as","","df","gh"}
StringUtils.splitPreserveAllTokens(",as,,,df,,",",")) = {"","as","","","df","",""}
StringUtils.splitPreserveAllTokens("as.df.gh",",")) = {"as.df.gh"}
StringUtils.splitPreserveAllTokens("as.df.gh","")) = {"as.df.gh"}
61.public static String[] splitPreserveAllTokens(String str, String separatorChars, int max)
和上面几个类似,只是指定了数组的最大长度。
如果max为0或负数,则认为没有限制。
这里不再举例。
62.public static String join(Object[] array)
把数组中的元素连接成一个字符串返回。
举例(*表示任意):
StringUtils.join(null) = null
StringUtils.join({}) = ""
StringUtils.join({"as","df","gh","jk"})) = "asdfghjk"
StringUtils.join({"as","","df","gh"})) = "asdfgh"
StringUtils.join({"","as","","","df","",""})) = "asdf"
63.public static String join(Object[] array, char separator)
把数组中的元素连接成一个字符串返回,把分隔符separator也加上。
举例(*表示任意):
StringUtils.join(null, *) = null
StringUtils.join({}, *) = ""
StringUtils.join({null}, *) = ""
StringUtils.join({"as","df","gh","jk"},' ')) = "as df gh jk"
StringUtils.join({"as","df","gh","jk"},'.')) = "as.df.gh.jk"
StringUtils.join({"as","","df","gh"},'.')) = "as..df.gh"
StringUtils.join({"","as","","","df","",""},','))= ",as,,,df,,"
StringUtils.join({"","as","","","df","",""},' '))= " as df "
StringUtils.join({"as.df.gh"},'.')) = "as.df.gh"
StringUtils.join({"as.df.gh"},' ')) = "as.df.gh"
64.public static String join(Object[] array, char separator, int startIndex, int endIndex)
把数组中的元素连接成一个字符串返回,把分隔符separator也加上。
连接的开始位置为startIndex,结束位置为endIndex。
这里不再举例。
65.public static String join(Object[] array, String separator)
与63类似,这里不再举例。
66.public static String join(Object[] array, String separator, int startIndex, int endIndex)
与64类似,这里不再举例。
判断是否字符串str不包含字符数组invalidChars中的字符,如果含有则返回false。
举例(*表示任意):
StringUtils.containsNone(null, *) = true
StringUtils.containsNone(*, []) = true
StringUtils.containsNone("", *) = true
StringUtils.containsNone("ab", []) = true
StringUtils.containsNone("b", ['a','f',' ']) = true
StringUtils.containsNone("bcd", ['a','f',' ']) = true
StringUtils.containsNone("abc", ['a','f',' ']) = false
StringUtils.containsNone(" ", ['a','f',' ']) = false
37.public static boolean containsNone(String str, String invalidChars)
判断是否字符串str不包含字符串invalidChars中的字符,如果含有则返回false。
举例(*表示任意):
StringUtils.containsNone(null, *) = true
StringUtils.containsNone(*, null) = true
StringUtils.containsNone("", *) = true
StringUtils.containsNone("ab", "") = true
StringUtils.containsNone("b", "af ") = true
StringUtils.containsNone("bcd", "af ") = true
StringUtils.containsNone("abc", "af ") = false
StringUtils.containsNone(" ", "af ") = false
38.public static int indexOfAny(String str, String[] searchStrs)
找出字符串数组searchStrs中的字符串第一次出现在字符串str中的位置。
如果数组中没有字符串在str中,则返回-1
如果数组为null或长度为0,则返回-1
举例(*表示任意):
StringUtils.indexOfAny(null, *) = -1
StringUtils.indexOfAny(*, null) = -1
StringUtils.indexOfAny(*, []) = -1
StringUtils.indexOfAny("", [""]) = 0
StringUtils.indexOfAny("bbeegg", ["as","df","yy"]) = -1
StringUtils.indexOfAny("asdfgh", ["as","df","yy"]) = 0
StringUtils.indexOfAny("dfasgh", ["as","df","yy"]) = 0
StringUtils.indexOfAny("ghasdf", ["as","df","yy"]) = 2
39.public static int lastIndexOfAny(String str, String[] searchStrs)
找出字符串数组searchStrs中的字符串最后一次出现在字符串str中的位置。
如果数组中没有字符串在str中,则返回-1
如果数组为null或长度为0,则返回-1
举例(*表示任意):
StringUtils.lastIndexOfAny(null, *) = -1
StringUtils.lastIndexOfAny(*, null) = -1
StringUtils.lastIndexOfAny(*, []) = -1
StringUtils.lastIndexOfAny("", [""]) = 0
StringUtils.lastIndexOfAny("bbeegg", ["as","df","yy"]) = -1
StringUtils.lastIndexOfAny("asdfgh", ["as","df","yy"]) = 2
StringUtils.lastIndexOfAny("dfghjk", ["as","df","yy"]) = 0
StringUtils.lastIndexOfAny("ghasdf", ["as","df","yy"]) = 4
StringUtils.lastIndexOfAny("ghasdf", ["as","df",""]) = 6
40.public static String substring(String str, int start)
得到字符串str的子串。
如果start小于0,位置是从后往前数的第|start|个
如果str为null或"",则返回它本身
举例(*表示任意):
StringUtils.substring(null, *) = null
StringUtils.substring("", *) = ""
StringUtils.substring("asdf", 0)) = "asdf"
StringUtils.substring("asdf", 1)) = "sdf"
StringUtils.substring("asdf", 3)) = "f"
StringUtils.substring("asdf",) = ""
StringUtils.substring("asdf", -1)) = "f"
StringUtils.substring("asdf", -3)) = "sdf"
StringUtils.substring("asdf", -8)) = "asdf"
41.public static String substring(String str, int start, int end)
得到字符串str的子串。
如果start小于0,位置是从后往前数的第|start|个,
如果end小于0,位置是从后往前数的第|end|个,
如果str为null或"",则返回它本身
举例(*表示任意):
StringUtils.substring(null, *, *) = null
StringUtils.substring("", * , *) = "";
StringUtils.substring("asdf", 0, 2) = "as"
StringUtils.substring("asdf", 0, -1) = "asd"
StringUtils.substring("asdf", 2, -1) = "d"
StringUtils.substring("asdf", 2, -2) = ""
StringUtils.substring("asdf", 3, 2) = ""
StringUtils.substring("asdf", 1, = "sdf"
StringUtils.substring("asdf", -1, -3) = ""
StringUtils.substring("asdf", -3, -1) = "sd"
StringUtils.substring("asdf", -8, 5) = "asdf"
42.public static String left(String str, int len)
得到字符串str从左边数len长度的子串。
如果str为null或为"",则返回它本身
如果len小于0,则返回""
举例(*表示任意):
StringUtils.left(null, *) = null
StringUtils.left(*, -ve) = ""
StringUtils.left("", *) = ""
StringUtils.left("asdf", 0) = ""
StringUtils.left("asdf", 2) = "as"
StringUtils.left("asdf", = "asdf"
43.public static String right(String str, int len)
得到字符串str从右边数len长度的子串。
如果str为null或为"",则返回它本身
如果len小于0,则返回""
举例(*表示任意):
StringUtils.right(null, *) = null
StringUtils.right(*, -ve) = ""
StringUtils.right("", *) = ""
StringUtils.right("asdf", 0) = ""
StringUtils.right("asdf", 2) = "df"
StringUtils.right("asdf", = "asdf"
44.public static String mid(String str, int pos, int len)
得到字符串str从pos开始len长度的子串。
如果str为null或为"",则返回它本身
如果len小于0或pos大于srt的长度,则返回""
如果pos小于0,则pos设为0
举例(*表示任意):
StringUtils.mid(null, *, *) = null
StringUtils.mid("", *, *) = ""
StringUtils.mid(*, *, -ve) = ""
StringUtils.mid("asdf", 0, 4)) = "asdf"
StringUtils.mid("asdf", 2, 2)) = "df"
StringUtils.mid("asdf", 2, 5)) = "df"
StringUtils.mid("asdf", -2, 1)) = "a"
StringUtils.mid("asdf", 0, -1)) = ""
45.public static String substringBefore(String str, String separator)
得到字符串str的在字符串separator出现前的字串,且separator不包括在内。
如果str为null或为"",则返回它本身
如果separator为null,则返回str本身
举例(*表示任意):
StringUtils.substringBefore(null, *) = null
StringUtils.substringBefore("", *) = ""
StringUtils.substringBefore("asdfg", null)) = "asdfg"
StringUtils.substringBefore("asdfg", "a")) = ""
StringUtils.substringBefore("asdfg", "sd")) = "a"
StringUtils.substringBefore("asdfsag", "sa")) = "asdf"
StringUtils.substringBefore("asdfg", "h")) = "asdfg"
StringUtils.substringBefore("asdfg", "")) = ""
StringUtils.substringBefore("asdfg", "dfgh")) = "asdfg"
StringUtils.substringBefore("asdfg", "dfg")) = "as"
StringUtils.substringBefore("abbbabbba", "bb")) = "a"
46.public static String substringAfter(String str, String separator)
得到字符串str的在字符串separator出现后的字串,且separator不包括在内。
如果str为null或为"",则返回它本身
如果separator为null,则返回""
举例(*表示任意):
StringUtils.substringAfter(null, *) = null
StringUtils.substringAfter("", *) = ""
StringUtils.substringAfter(*, null) = ""
StringUtils.substringAfter("asdfg", "a")) = "sdfg"
StringUtils.substringAfter("asdfg", "sd")) = "fg"
StringUtils.substringAfter("asdfsag", "sa")) = "g"
StringUtils.substringAfter("asdfg", "h")) = ""
StringUtils.substringAfter("asdfg", "")) = "asdfg"
StringUtils.substringAfter("asdfg", "dfgh")) = ""
StringUtils.substringAfter("asdfg", "dfg")) = ""
StringUtils.substringAfter("abbbabbba", "bb"))= "babbba"
47.public static String substringBeforeLast(String str, String separator)
和45类似,得到字符串str的在字符串separator最后一次出现前的字串。
这里不再举例。
48.public static String substringAfterLast(String str, String separator)
和46类似,得到字符串str的在字符串separator最后一次出现后的字串。
这里不再举例。
49.public static String substringBetween(String str, String tag)
得到str中的在两个字符串tag中间的字符串,即str中的tag所夹的串。
如果str为null或tag为null,返回null
举例(*表示任意):
StringUtils.substringBetween(null, *) = null
StringUtils.substringBetween(*, null) = null
StringUtils.substringBetween("", "") = ""
StringUtils.substringBetween("", "a")) = null
StringUtils.substringBetween("asdfdf", "df")) = ""
StringUtils.substringBetween("asdfas", "as")) = "df"
StringUtils.substringBetween("dfasdfasdfas", "df")) = "as"
StringUtils.substringBetween("dfasdfasdfas", "as")) = "df"
StringUtils.substringBetween("dfasdfasgdf", "df")) = "as"
50.public static String substringBetween(String str, String open, String close)
得到str中的在两个字符串open和close中间的字符串,即open和close所夹的串。
如果str为null或open为null或close为null,返回null
举例(*表示任意):
StringUtils.substringBetween(null, *, *) = null
StringUtils.substringBetween(*, null, *) = null
StringUtils.substringBetween(*, *, null) = null
StringUtils.substringBetween("", "", "") = ""
StringUtils.substringBetween("", "", "]") = null
StringUtils.substringBetween("", "[", "]") = null
StringUtils.substringBetween("[]", "[","]")) = ""
StringUtils.substringBetween("a[sd]f", "[","]")) = "sd"
StringUtils.substringBetween("a[sd]f[gh]", "[","]")) = "sd"
StringUtils.substringBetween("a[sd]f", "]","[")) = null
StringUtils.substringBetween("a[sd]f", "","")) = ""
51.public static String[] substringsBetween(String str, String open, String close)
得到str中的在两个字符串open和close中间的字符串,即open和close所夹的串,
把所有符合的结果放在数组中返回。
和50类似,但是返回了所有的结果(50只返回了第一个匹配的结果)。
这里不再举例。
52.public static String[] split(String str)
把字符串拆分成一个字符串数组,用空白符(whitespace)作为分隔符。
Whitespace是这样定义的 {@link Character#isWhitespace(char)}
如果字符串为null,返回null
如果字符串为"",返回空数组{}
举例(*表示任意):
StringUtils.split(null) = null
StringUtils.split("") = {}
StringUtils.split("as df yy")) = {"as","df","yy"}
StringUtils.split(" as df yy ")) = {"as","df","yy"}
StringUtils.split("as\ndf\ryy")) = {"as","df","yy"}
StringUtils.split("as\tdf\fyy")) = {"as","df","yy"}
StringUtils.split("as df \fyy")) = {"as","df","yy"}
StringUtils.split("as\t \r df \f \n yy")) = {"as","df","yy"}
StringUtils.split("as")) = {"as"}
StringUtils.split(" as ")) = {"as"}
53.public static String[] split(String str, char separatorChar)
把字符串拆分成一个字符串数组,用指定的字符separatorChar作为分隔符。
如果字符串为null,返回null
如果字符串为"",返回空数组{}
举例(*表示任意):
StringUtils.split(null, *) = null
StringUtils.split("", *) = {}
StringUtils.split("as df yy",' ')) = {"as","df","yy"}
StringUtils.split(" as df yy ",' ')) = {"as","df","yy"}
StringUtils.split("asodfoyy",'o')) = {"as","df","yy"}
StringUtils.split("as.df.yy",'.')) = {"as","df","yy"}
StringUtils.split("as\ndf\nyy",'\n'))= {"as","df","yy"}
StringUtils.split("as",' ')) = {"as"}
StringUtils.split(" as ",' ')) = {"as"}
54.public static String[] split(String str, String separatorChars)
把字符串拆分成一个字符串数组,用指定的字符串separatorChars作为分隔符。
如果字符串str为null,返回null
如果字符串str为"",返回空数组{}
如果separatorChars为null,则默认为空白符
和53类似。
举例(*表示任意):
StringUtils.split("as \rdf \t yy",null)) = {"as","df","yy"}
StringUtils.split("as\ndf\fyy",null)) = {"as","df","yy"}
StringUtils.split("as","")) = {"as"}
55.public static String[] split(String str, String separatorChars, int max)
把字符串拆分成一个字符串数组,用指定的字符串separatorChars作为分隔符,
数组的最大长度为max。
如果字符串str为null,返回null
如果字符串str为"",返回空数组{}
如果separatorChars为null,则默认为空白符
如果max小于等于0,认为是没有限制
举例(*表示任意):
StringUtils.split(null, *, *) = null
StringUtils.split("", *, *) = {}
StringUtils.split("as df yy",null,0)) = {"as","df","yy"}
StringUtils.split("as df yy"," ",0)) = {"as","df","yy"}
StringUtils.split("as.df.yy",".",-1)) = {"as","df","yy"}
StringUtils.split("as.df.yy",".",4)) = {"as","df","yy"}
StringUtils.split("as-!-df-!-yy","-!-",0)) = {"as","df","yy"}
StringUtils.split("as.df.yy",".",2)) = {"as","df.yy"}
StringUtils.split("as","",0)) = {"as"}
StringUtils.split("as","",2)) = {"as"}
56.public static String[] splitByWholeSeparator(String str, String separator)
个人认为和54功能一样。区别有待发掘。
57.public static String[] splitByWholeSeparator( String str, String separator, int max )
个人认为和55功能一样。区别有待发掘。
58.public static String[] splitPreserveAllTokens(String str)
把字符串str拆分成一个数组,用空白符(whitespace)作为分隔符,保留所有的标识,
包括相邻分隔符产生的空的标识。它可作为StringTokenizer的一个替代。
Whitespace是这样定义的{@link Character#isWhitespace(char)}。
举例(*表示任意):
StringUtils.splitPreserveAllTokens(null)) = null
StringUtils.splitPreserveAllTokens("")) = {}
StringUtils.splitPreserveAllTokens("as df gh jk")) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as\ndf\rgh\fjk")) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as\tdf gh jk")) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as df gh")) = {"as","","df","gh"}
StringUtils.splitPreserveAllTokens(" as df ")) = {"","as","","","df","",""}
59.public static String[] splitPreserveAllTokens(String str, char separatorChar)
和58类似,只是分隔符为字符separatorChar。
举例(*表示任意):
StringUtils.splitPreserveAllTokens(null, *) = null
StringUtils.splitPreserveAllTokens("", *) = {}
StringUtils.splitPreserveAllTokens("as df gh jk",' ')) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as.df.gh.jk",'.')) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as..df.gh",'.')) = {"as","","df","gh"}
StringUtils.splitPreserveAllTokens(",as,,,df,,",',')) = {"","as","","","df","",""}
StringUtils.splitPreserveAllTokens("as.df.gh",',')) = {"as.df.gh"}
60.public static String[] splitPreserveAllTokens(String str, String separatorChars)
和59类似,只是分隔符为字符串separatorChars。
举例(*表示任意):
StringUtils.splitPreserveAllTokens(null, *) = null
StringUtils.splitPreserveAllTokens("", *) = {}
StringUtils.splitPreserveAllTokens("as df gh jk",null)) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as\ndf\rgh\fjk",null))= {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as df gh jk"," ")) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as.df.gh.jk",".")) = {"as","df","gh","jk"}
StringUtils.splitPreserveAllTokens("as..df.gh",".")) = {"as","","df","gh"}
StringUtils.splitPreserveAllTokens(",as,,,df,,",",")) = {"","as","","","df","",""}
StringUtils.splitPreserveAllTokens("as.df.gh",",")) = {"as.df.gh"}
StringUtils.splitPreserveAllTokens("as.df.gh","")) = {"as.df.gh"}
61.public static String[] splitPreserveAllTokens(String str, String separatorChars, int max)
和上面几个类似,只是指定了数组的最大长度。
如果max为0或负数,则认为没有限制。
这里不再举例。
62.public static String join(Object[] array)
把数组中的元素连接成一个字符串返回。
举例(*表示任意):
StringUtils.join(null) = null
StringUtils.join({}) = ""
StringUtils.join({"as","df","gh","jk"})) = "asdfghjk"
StringUtils.join({"as","","df","gh"})) = "asdfgh"
StringUtils.join({"","as","","","df","",""})) = "asdf"
63.public static String join(Object[] array, char separator)
把数组中的元素连接成一个字符串返回,把分隔符separator也加上。
举例(*表示任意):
StringUtils.join(null, *) = null
StringUtils.join({}, *) = ""
StringUtils.join({null}, *) = ""
StringUtils.join({"as","df","gh","jk"},' ')) = "as df gh jk"
StringUtils.join({"as","df","gh","jk"},'.')) = "as.df.gh.jk"
StringUtils.join({"as","","df","gh"},'.')) = "as..df.gh"
StringUtils.join({"","as","","","df","",""},','))= ",as,,,df,,"
StringUtils.join({"","as","","","df","",""},' '))= " as df "
StringUtils.join({"as.df.gh"},'.')) = "as.df.gh"
StringUtils.join({"as.df.gh"},' ')) = "as.df.gh"
64.public static String join(Object[] array, char separator, int startIndex, int endIndex)
把数组中的元素连接成一个字符串返回,把分隔符separator也加上。
连接的开始位置为startIndex,结束位置为endIndex。
这里不再举例。
65.public static String join(Object[] array, String separator)
与63类似,这里不再举例。
66.public static String join(Object[] array, String separator, int startIndex, int endIndex)
与64类似,这里不再举例。
发表评论
-
Quercus框架
2014-03-02 17:40 1132由于对Java比较熟悉,开发Java Web程序前端是用JS ... -
如何将JBoss注册为Windows服务
2011-08-17 17:06 1879我们有一台Windows Server 2003的操作系统,主 ... -
linux下安装jdk及配置环境变量
2011-07-19 12:00 12871.安装jdk 传输文件jdk-6u26-linux-x64- ... -
apache commons-lang-2.3 StringUtils.java 学习笔记(4)
2009-02-03 15:46 271267.public static String deleteW ... -
apache commons-lang-2.3 StringUtils.java 学习笔记(2)
2009-02-03 15:34 2544以下方法只介绍其功能 ... -
apache commons-lang-2.3 StringUtils.java 学习笔记(1)
2009-02-03 15:24 1589以前写在其他博客上的,现在搬到这里。我是越来越喜欢这里了,呵呵 ...
相关推荐
赠送jar包:commons-pool2-2.3.jar; 赠送原API文档:commons-pool2-2.3-javadoc.jar; 赠送源代码:commons-pool2-2.3-sources.jar; 赠送Maven依赖信息文件:commons-pool2-2.3.pom; 包含翻译后的API文档:...
commons-lang3.3.1.jar、Apache Commons包中的一个,包含了一些数据类型工具类,是java.lang.*的扩展。必须使用的jar包。为JRE5.0+的更好的版本所提供 Jar文件包含的类: META-INF/MANIFEST.MFMETA-INF/LICENSE....
/* 内含 common-lang3.jar commons-lang3-3.9-bin.zip commons-lang3-3.9-src.zip 使用说明.txt*/ public static String getClientIp(HttpServletRequest request) { String ip = request.getHeader("X-...
`commons-lang3-3.1.jar`是这个库的一个版本,其中包含了多个实用类和方法,有助于简化和优化Java开发工作。 `org.apache.commons.lang3.StringUtils`是Lang包中的一个关键类,它提供了大量与字符串操作相关的静态...
在给定的标题 "org.apache.commons.lang3.StringUtils.jar.rar" 中,我们可以看到这个压缩包包含的是 `StringUtils.jar`,实际上它是一个 `common-lang3.jar` 文件的别名。这个 JAR 包是 Apache Commons Lang 项目的...
commons-pool2-2.3.jar
赠送jar包:commons-lang3-3.9.jar; 赠送原API文档:commons-lang3-3.9-javadoc.jar; 赠送源代码:commons-lang3-3.9-sources.jar; 赠送Maven依赖信息文件:commons-lang3-3.9.pom; 包含翻译后的API文档:...
commons-lang3.3.1.jar、Apache Commons包中的一个,包含了一些数据类型工具类,是java.lang.*的扩展。必须使用的jar包。为JRE5.0+的更好的版本所提供 Jar文件包含的类: META-INF/MANIFEST.MFMETA-INF/LICENSE....
赠送jar包:commons-lang3-3.5.jar; 赠送原API文档:commons-lang3-3.5-javadoc.jar; 赠送源代码:commons-lang3-3.5-sources.jar; 赠送Maven依赖信息文件:commons-lang3-3.5.pom; 包含翻译后的API文档:...
赠送jar包:commons-lang3-3.12.0.jar; 赠送原API文档:commons-lang3-3.12.0-javadoc.jar; 赠送源代码:commons-lang3-3.12.0-sources.jar; 赠送Maven依赖信息文件:commons-lang3-3.12.0.pom; 包含翻译后的API...
在"commons-lang-2.3.tar.gz"这个压缩包中,包含了Apache Commons Lang 2.3版本的源代码和可能的编译结果。这个版本是针对Java开发者的,它提供了许多实用的类和方法,帮助开发者更加高效地进行编程。 标题中的...
commons-pool2-2.3.jar commons-pool2.jar是一个十分常用的jar文件,commons-pool2.jar文件适用于java开发中的与连接池进行连接部分使用,如果您缺少这个jar文件马上下载commons-pool2.jar吧
赠送jar包:commons-lang3-3.10.jar; 赠送原API文档:commons-lang3-3.10-javadoc.jar; 赠送源代码:commons-lang3-3.10-sources.jar; 赠送Maven依赖信息文件:commons-lang3-3.10.pom; 包含翻译后的API文档:...
赠送jar包:commons-lang3-3.4.jar; 赠送原API文档:commons-lang3-3.4-javadoc.jar; 赠送源代码:commons-lang3-3.4-sources.jar; 赠送Maven依赖信息文件:commons-lang3-3.4.pom; 包含翻译后的API文档:...
这个"commons-lang-2.4.rar"压缩包包含了两个子文件,分别是"commons-lang-2.4-bin.zip"和"commons-lang-2.4-src.zip"。 "commons-lang-2.4-bin.zip"文件是编译后的二进制版本,包含了commons-lang库的JAR文件。这...
赠送jar包:commons-lang-2.4.jar; 赠送原API文档:commons-lang-2.4-javadoc.jar; 赠送源代码:commons-lang-2.4-sources.jar; 赠送Maven依赖信息文件:commons-lang-2.4.pom; 包含翻译后的API文档:commons-...
赠送jar包:commons-lang3-3.10.jar; 赠送原API文档:commons-lang3-3.10-javadoc.jar; 赠送源代码:commons-lang3-3.10-sources.jar; 赠送Maven依赖信息文件:commons-lang3-3.10.pom; 包含翻译后的API文档:...
c3p0依赖包mchange-commons-java-0.2.19.jar; 特别说明:c3p0(c3p0-0.9.5.5.bin.tgz)的lib包里面含此mchange-commons-java-0.2.19.jar文件。
《Aduna Commons Lang 2.3.jar:Java编程中的实用工具库》 Aduna Commons Lang 2.3.jar 是一个广泛使用的Java库,它为Java开发者提供了大量的实用工具类和方法,极大地增强了Java标准库的功能。这个库由Aduna组织...
commons-lang-2.6.jar包commons-lang-2.6.jar包commons-lang-2.6.jar包commons-lang-2.6.jar包commons-lang-2.6.jar包加源码