- 浏览: 603091 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
Garlic_90:
ireport分页的话代码写起来有些复杂,我以前试过,比较简单 ...
ireport分页显示 -
feijiing:
nice,problem solved,thanks!
虚拟机安装centos no valid devices were found on which to cereate new file systems -
Jocken:
引用的jar包需要怎么加在命令里面?十多个呢,为什么配在MAN ...
linux 如何运行jar包 -
xiaoqiao800:
看到你的问题,有帮助,我之前都是手动的clear项目下的cla ...
The project cannot be built until build path errors are resolved -
mfkdzhou:
楼主好,我现在也遇到这个问题,可以把源代码发一份不?谢谢了。8 ...
java打印
转自http://tianlihu.iteye.com/blog/476874
StringUtil包函数
1.空字符串检查
使用函数: StringUtils.isBlank(testString)
函数介绍: 当testString为空,长度为零或者仅由空白字符(whitespace)组成时,返回True;否则返回False
例程:
Java代码 收藏代码
String test = "";
String test2 = "\n\n\t";
String test3 = null;
String test4 = "Test";
System.out.println( "test blank? " + StringUtils.isBlank( test ) );
System.out.println( "test2 blank? " + StringUtils.isBlank( test2 ) );
System.out.println( "test3 blank? " + StringUtils.isBlank( test3 ) );
System.out.println( "test4 blank? " + StringUtils.isBlank( test4 ) );
输出如下:
test blank? true
test2 blank? true
test3 blank? true
test4 blank? False
函数StringUtils.isNotBlank(testString)的功能与StringUtils.isBlank(testString)相反.
2.清除空白字符
使用函数: StringUtils.trimToNull(testString)
函数介绍:清除掉testString首尾的空白字符,如果仅testString全由空白字符
(whitespace)组成则返回null
例程:
Java代码 收藏代码
String test1 = "\t";
String test2 = " A Test ";
String test3 = null;
System.out.println( "test1 trimToNull: " + StringUtils.trimToNull( test1 ) );
System.out.println( "test2 trimToNull: " + StringUtils.trimToNull( test2 ) );
System.out.println( "test3 trimToNull: " + StringUtils.trimToNull( test3 ) );
输出如下:
test1 trimToNull: null
test2 trimToNull: A Test
test3 trimToNull: null
注意:函数StringUtils.trim(testString)与
StringUtils.trimToNull(testString)功能类似,但testString由空白字符
(whitespace)组成时返回零长度字符串。
3.取得字符串的缩写
使用函数: StringUtils.abbreviate(testString,width)和StringUtils.abbreviate(testString,offset,width)
函数介绍:在给定的width内取得testString的缩写,当testString的长度小于width则返回原字符串.
例程:
Java代码 收藏代码
String test = "This is a test of the abbreviation.";
String test2 = "Test";
System.out.println( StringUtils.abbreviate( test, 15 ) );
System.out.println( StringUtils.abbreviate( test, 5,15 ) );
System.out.println( StringUtils.abbreviate( test2, 10 ) );
输出如下:
This is a te...
...is a test...
Test
4.劈分字符串
使用函数: StringUtils.split(testString,splitChars,arrayLength)
函数介绍:splitChars中可以包含一系列的字符串来劈分testString,并可以设定得
到数组的长度.注意设定长度arrayLength和劈分字符串间有抵触关系,建议一般情况下
不要设定长度.
例程:
Java代码 收藏代码
String input = "A b,c.d|e";
String input2 = "Pharmacy, basketball funky";
String[] array1 = StringUtils.split(input, " ,.|");
String[] array2 = StringUtils.split(input2, " ,", 2);
System.out.println(ArrayUtils.toString(array1));
System.out.println(ArrayUtils.toString(array2));
输出如下:
{A,b,c,d,e}
{Pharmacy,basketball funky}
5.查找嵌套字符串
使用函数:StringUtils.substringBetween(testString,header,tail)
函数介绍:在testString中取得header和tail之间的字符串。不存在则返回空
例程:
Java代码 收藏代码
String htmlContent = "ABC1234ABC4567";
System.out.println(StringUtils.substringBetween(htmlContent, "1234", "4567"));
System.out.println(StringUtils.substringBetween(htmlContent, "12345", "4567"));
输出如下:
ABC
null
6.去除尾部换行符
使用函数:StringUtils.chomp(testString)
函数介绍:去除testString尾部的换行符
例程:
Java代码 收藏代码
String input = "Hello\n";
System.out.println(StringUtils.chomp(input));
String input2 = "Another test\r\n";
System.out.println(StringUtils.chomp(input2));
输出如下:
Hello
Another test
7.重复字符串
使用函数:StringUtils.repeat(repeatString,count)
函数介绍:得到将repeatString重复count次后的字符串
例程:
Java代码 收藏代码
System.out.println( StringUtils.repeat( "*", 10));
System.out.println( StringUtils.repeat( "China ", 5));
输出如下:
**********
China China China China China
其他函数:StringUtils.center( testString, count,repeatString );
函数介绍:把testString插入将repeatString重复多次后的字符串中间,得到字符串
的总长为count
例程:
Java代码 收藏代码
System.out.println( StringUtils.center( "China", 11,"*"));
输出如下:
***China***
8.颠倒字符串
使用函数:StringUtils.reverse(testString)
函数介绍:得到testString中字符颠倒后的字符串
例程:
Java代码 收藏代码
System.out.println( StringUtils.reverse("ABCDE"));
输出如下:
EDCBA
9.判断字符串内容的类型
函数介绍:
Java代码 收藏代码
StringUtils.isNumeric( testString ) //如果testString全由数字组成返回True
StringUtils.isAlpha( testString ) //如果testString全由字母组成返回True
StringUtils.isAlphanumeric( testString ) //如果testString全由数字或数字组
成返回True
Java代码 收藏代码
StringUtils.isAlphaspace( testString ) //如果testString全由字母或空格组
成返回True
例程:
Java代码 收藏代码
String state = "Virginia";
System.out.println("Is state number? " + StringUtils.isNumeric(state));
System.out.println("Is state alpha? " + StringUtils.isAlpha(state));
System.out.println("Is state alphanumeric? " + StringUtils.isAlphanumeric(state));
System.out.println("Is state alphaspace? " + StringUtils.isAlphaSpace(state));
输出如下:
Is state number? false
Is state alpha? true
Is state alphanumeric? true
Is state alphaspace? true
10.取得某字符串在另一字符串中出现的次数
使用函数:StringUtils.countMatches(testString,seqString)
函数介绍:取得seqString在testString中出现的次数,未发现则返回零
例程:
Java代码 收藏代码
System.out.println(StringUtils.countMatches( "Chinese People", "e"
));
输出:
4
11.部分截取字符串
使用函数:
Java代码 收藏代码
StringUtils.substringBetween(testString,fromString,toString )//取得两字符之间的字符串
StringUtils.substringAfter( )//取得指定字符串后的字符串
StringUtils.substringBefore( )//取得指定字符串之前的字符串
StringUtils.substringBeforeLast( )//取得最后一个指定字符串之前的字符串
StringUtils.substringAfterLast( )//取得最后一个指定字符串之后的字符串
函数介绍:上面应该都讲明白了吧。
例程:
Java代码 收藏代码
String formatted = " 25 * (30,40) [50,60] | 30";
System.out.print("N0: " + StringUtils.substringBeforeLast(formatted, "*"));
System.out.print(", N1: " + StringUtils.substringBetween(formatted, "(", ","));
System.out.print(", N2: " + StringUtils.substringBetween(formatted, ",", ")"));
System.out.print(", N3: " + StringUtils.substringBetween(formatted, "[", ","));
System.out.print(", N4: " + StringUtils.substringBetween(formatted, ",", "]"));
System.out.print(", N5: " + StringUtils.substringAfterLast(formatted, "|"));
输出如下:
N0: 25 , N1: 30, N2: 40, N3: 50, N4: 40) [50,60, N5: 30
---------------------------------------------------------------------------------------------------------------------------------------
一、数组转成字符串:
1、 将数组中的字符转换为一个字符串
将数组中的字符转换为一个字符串
Java代码 收藏代码
@param strToConv 要转换的字符串 ,默认以逗号分隔
@return 返回一个字符串
String[3] s={"a","b","c"}
StringUtil.convString(s)="a,b,c"
2、
Java代码 收藏代码
static public String converString(String strToConv)
@param strToConv 要转换的字符串 ,
@param conv 分隔符,默认以逗号分隔
@return 同样返回一个字符串
String[3] s={"a","b","c"}
StringUtil.convString(s,"@")="a@b@c"
static public String converString(String strToConv, String conv)
二、空值检测:
3、
Java代码 收藏代码
Checks if a String is empty ("") or null.
判断一个字符串是否为空,空格作非空处理。
Java代码 收藏代码
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0.
It no longer trims the String.
That functionality is available in isBlank().
Java代码 收藏代码
@param str the String to check, may be null
@return true if the String is empty or null
public static boolean isEmpty(String str)
三、非空处理:
4、
Checks if a String is not empty ("") and not null.
判断一个字符串是否非空,空格作非空处理.
Java代码 收藏代码
StringUtils.isNotEmpty(null) = false
StringUtils.isNotEmpty("") = false
StringUtils.isNotEmpty(" ") = true
StringUtils.isNotEmpty("bob") = true
StringUtils.isNotEmpty(" bob ") = true
@param str the String to check, may be null
@return true if the String is not empty and not null
public static boolean isNotEmpty(String str)
5、
Checks if a String is not empty (""), not null and not whitespace only.
判断一个字符串是否非空,空格作空处理.
Java代码 收藏代码
StringUtils.isNotBlank(null) = false
StringUtils.isNotBlank("") = false
StringUtils.isNotBlank(" ") = false
StringUtils.isNotBlank("bob") = true
StringUtils.isNotBlank(" bob ") = true
@param str the String to check, may be null
@return true if the String is not empty and not null and not whitespace
@since 2.0
public static boolean isNotBlank(String str)
四、 空格处理
6、
Removes control characters (char <= 32) from both
ends of this String, handling null by returning
null.
The String is trimmed using {@link String#trim()}.
Trim removes start and end characters <= 32.
To strip whitespace use {@link //strip(String)}.
To trim your choice of characters, use the
{@link //strip(String, String)} methods.
格式化一个字符串中的空格,有非空判断处理;
Java代码 收藏代码
StringUtils.trim(null) = null
StringUtils.trim("") = ""
StringUtils.trim(" ") = ""
StringUtils.trim("abc") = "abc"
StringUtils.trim(" abc ") = "abc"
@param str the String to be trimmed, may be null
@return the trimmed string, null if null String input
public static String trim(String str)
7、
Removes control characters (char <= 32) from both
ends of this String returning null if the String is
empty ("") after the trim or if it is null.
The String is trimmed using {@link String#trim()}.
Trim removes start and end characters <= 32.
To strip whitespace use {@link /stripToNull(String)}.
格式化一个字符串中的空格,有非空判断处理,如果为空返回null;
Java代码 收藏代码
StringUtils.trimToNull(null) = null
StringUtils.trimToNull("") = null
StringUtils.trimToNull(" ") = null
StringUtils.trimToNull("abc") = "abc"
StringUtils.trimToNull(" abc ") = "abc"
@param str the String to be trimmed, may be null
@return the trimmed String,
null if only chars <= 32, empty or null String input
@since 2.0
public static String trimToNull(String str)
8、
Removes control characters (char <= 32) from both
ends of this String returning an empty String ("") if the String
is empty ("") after the trim or if it is null.
The String is trimmed using {@link String#trim()}.
Trim removes start and end characters <= 32.
To strip whitespace use {@link /stripToEmpty(String)}.
格式化一个字符串中的空格,有非空判断处理,如果为空返回"";
Java代码 收藏代码
StringUtils.trimToEmpty(null) = ""
StringUtils.trimToEmpty("") = ""
StringUtils.trimToEmpty(" ") = ""
StringUtils.trimToEmpty("abc") = "abc"
StringUtils.trimToEmpty(" abc ") = "abc"
@param str the String to be trimmed, may be null
@return the trimmed String, or an empty String if null input
@since 2.0
public static String trimToEmpty(String str)
五、 字符串比较:
9、
Compares two Strings, returning true if they are equal.
nulls are handled without exceptions. Two null
references are considered to be equal. The comparison is case sensitive.
判断两个字符串是否相等,有非空处理。
Java代码 收藏代码
StringUtils.equals(null, null) = true
StringUtils.equals(null, "abc") = false
StringUtils.equals("abc", null) = false
StringUtils.equals("abc", "abc") = true
StringUtils.equals("abc", "ABC") = false
@param str1 the first String, may be null
@param str2 the second String, may be null
@return true if the Strings are equal, case sensitive, or
both null
@see java.lang.String#equals(Object)
public static boolean equals(String str1, String str2)
10、
Compares two Strings, returning true if they are equal ignoring
the case.
nulls are handled without exceptions. Two null
references are considered equal. Comparison is case insensitive.
判断两个字符串是否相等,有非空处理。忽略大小写
Java代码 收藏代码
StringUtils.equalsIgnoreCase(null, null) = true
StringUtils.equalsIgnoreCase(null, "abc") = false
StringUtils.equalsIgnoreCase("abc", null) = false
StringUtils.equalsIgnoreCase("abc", "abc") = true
StringUtils.equalsIgnoreCase("abc", "ABC") = true
@param str1 the first String, may be null
@param str2 the second String, may be null
@return true if the Strings are equal, case insensitive, or
both null
@see java.lang.String#equalsIgnoreCase(String)
public static boolean equalsIgnoreCase(String str1, String str2)
六、 IndexOf 处理
11、
Finds the first index within a String, handling null.
This method uses {@link String#indexOf(String)}.
A null String will return -1.
返回要查找的字符串所在位置,有非空处理
Java代码 收藏代码
StringUtils.indexOf(null, *) = -1
StringUtils.indexOf(*, null) = -1
StringUtils.indexOf("", "") = 0
StringUtils.indexOf("aabaabaa", "a") = 0
StringUtils.indexOf("aabaabaa", "b") = 2
StringUtils.indexOf("aabaabaa", "ab") = 1
StringUtils.indexOf("aabaabaa", "") = 0
@param str the String to check, may be null
@param searchStr the String to find, may be null
@return the first index of the search String,
-1 if no match or null string input
@since 2.0
public static int indexOf(String str, String searchStr)
12、
Finds the first index within a String, handling null.
This method uses {@link String#indexOf(String, int)}.
A null String will return -1.
A negative start position is treated as zero.
An empty ("") search String always matches.
A start position greater than the string length only matches
an empty search String.
返回要由指定位置开始查找的字符串所在位置,有非空处理
Java代码 收藏代码
StringUtils.indexOf(null, *, *) = -1
StringUtils.indexOf(*, null, *) = -1
StringUtils.indexOf("", "", 0) = 0
StringUtils.indexOf("aabaabaa", "a", 0) = 0
StringUtils.indexOf("aabaabaa", "b", 0) = 2
StringUtils.indexOf("aabaabaa", "ab", 0) = 1
StringUtils.indexOf("aabaabaa", "b", 3) = 5
StringUtils.indexOf("aabaabaa", "b", 9) = -1
StringUtils.indexOf("aabaabaa", "b", -1) = 2
StringUtils.indexOf("aabaabaa", "", 2) = 2
StringUtils.indexOf("abc", "", 9) = 3
@param str the String to check, may be null
@param searchStr the String to find, may be null
@param startPos the start position, negative treated as zero
@return the first index of the search String, -1 if no match or null string input
@since 2.0
public static int indexOf(String str, String searchStr, int startPos)
七、 子字符串处理:
13、
Gets a substring from the specified String avoiding exceptions.
A negative start position can be used to start n
characters from the end of the String.
A null String will return null.
An empty ("") String will return "".
返回指定位置开始的字符串中的所有字符
Java代码 收藏代码
StringUtils.substring(null, *) = null
StringUtils.substring("", *) = ""
StringUtils.substring("abc", 0) = "abc"
StringUtils.substring("abc", 2) = "c"
StringUtils.substring("abc", 4) = ""
StringUtils.substring("abc", -2) = "bc"
StringUtils.substring("abc", -4) = "abc"
@param str the String to get the substring from, may be null
@param start the position to start from, negative means
count back from the end of the String by this many characters
@return substring from start position, null if null String input
public static String substring(String str, int start)
14、
Gets a substring from the specified String avoiding exceptions.
A negative start position can be used to start/end n
characters from the end of the String.
The returned substring starts with the character in the start
position and ends before the end position. All postion counting is
zero-based -- i.e., to start at the beginning of the string use
start = 0. Negative start and end positions can be used to
specify offsets relative to the end of the String.
If start is not strictly to the left of end, ""
is returned.
返回由开始位置到结束位置之间的子字符串
Java代码 收藏代码
StringUtils.substring(null, *, *) = null
StringUtils.substring("", * , *) = "";
StringUtils.substring("abc", 0, 2) = "ab"
StringUtils.substring("abc", 2, 0) = ""
StringUtils.substring("abc", 2, 4) = "c"
StringUtils.substring("abc", 4, 6) = ""
StringUtils.substring("abc", 2, 2) = ""
StringUtils.substring("abc", -2, -1) = "b"
StringUtils.substring("abc", -4, 2) = "ab"
@param str the String to get the substring from, may be null
@param start the position to start from, negative means
count back from the end of the String by this many characters
@param end the position to end at (exclusive), negative means
count back from the end of the String by this many characters
@return substring from start position to end positon,
null if null String input
public static String substring(String str, int start, int end)
15、 SubStringAfter/SubStringBefore(前后子字符串处理:
Gets the substring before the first occurance of a separator.
The separator is not returned.
A null string input will return null.
An empty ("") string input will return the empty string.
A null separator will return the input string.
返回指定字符串之前的所有字符
Java代码 收藏代码
StringUtils.substringBefore(null, *) = null
StringUtils.substringBefore("", *) = ""
StringUtils.substringBefore("abc", "a") = ""
StringUtils.substringBefore("abcba", "b") = "a"
StringUtils.substringBefore("abc", "c") = "ab"
StringUtils.substringBefore("abc", "d") = "abc"
StringUtils.substringBefore("abc", "") = ""
StringUtils.substringBefore("abc", null) = "abc"
@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring before the first occurance of the separator,
null if null String input
@since 2.0
public static String substringBefore(String str, String separator)
16、
Gets the substring after the first occurance of a separator.
The separator is not returned.
A null string input will return null.
An empty ("") string input will return the empty string.
A null separator will return the empty string if the
input string is not null.
返回指定字符串之后的所有字符
Java代码 收藏代码
StringUtils.substringAfter(null, *) = null
StringUtils.substringAfter("", *) = ""
StringUtils.substringAfter(*, null) = ""
StringUtils.substringAfter("abc", "a") = "bc"
StringUtils.substringAfter("abcba", "b") = "cba"
StringUtils.substringAfter("abc", "c") = ""
StringUtils.substringAfter("abc", "d") = ""
StringUtils.substringAfter("abc", "") = "abc"
@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring after the first occurance of the separator,
null if null String input
@since 2.0
public static String substringAfter(String str, String separator)
17、
Gets the substring before the last occurance of a separator.
The separator is not returned.
A null string input will return null.
An empty ("") string input will return the empty string.
An empty or null separator will return the input string.
返回最后一个指定字符串之前的所有字符
Java代码 收藏代码
StringUtils.substringBeforeLast(null, *) = null
StringUtils.substringBeforeLast("", *) = ""
StringUtils.substringBeforeLast("abcba", "b") = "abc"
StringUtils.substringBeforeLast("abc", "c") = "ab"
StringUtils.substringBeforeLast("a", "a") = ""
StringUtils.substringBeforeLast("a", "z") = "a"
StringUtils.substringBeforeLast("a", null) = "a"
StringUtils.substringBeforeLast("a", "") = "a"
@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring before the last occurance of the separator,
null if null String input
@since 2.0
public static String substringBeforeLast(String str, String separator)
18、
Gets the substring after the last occurance of a separator.
The separator is not returned.
A null string input will return null.
An empty ("") string input will return the empty string.
An empty or null separator will return the empty string if
the input string is not null.
返回最后一个指定字符串之后的所有字符
Java代码 收藏代码
StringUtils.substringAfterLast(null, *) = null
StringUtils.substringAfterLast("", *) = ""
StringUtils.substringAfterLast(*, "") = ""
StringUtils.substringAfterLast(*, null) = ""
StringUtils.substringAfterLast("abc", "a") = "bc"
StringUtils.substringAfterLast("abcba", "b") = "a"
StringUtils.substringAfterLast("abc", "c") = ""
StringUtils.substringAfterLast("a", "a") = ""
StringUtils.substringAfterLast("a", "z") = ""
@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring after the last occurance of the separator,
null if null String input
@since 2.0
public static String substringAfterLast(String str, String separator)
八、 Replacing(字符串替换)
19、
Replaces all occurances of a String within another String.
A null reference passed to this method is a no-op.
以指定字符串替换原来字符串的的指定字符串
Java代码 收藏代码
StringUtils.replace(null, *, *) = null
StringUtils.replace("", *, *) = ""
StringUtils.replace("aba", null, null) = "aba"
StringUtils.replace("aba", null, null) = "aba"
StringUtils.replace("aba", "a", null) = "aba"
StringUtils.replace("aba", "a", "") = "aba"
StringUtils.replace("aba", "a", "z") = "zbz"
@param text text to search and replace in, may be null
@param repl the String to search for, may be null
@param with the String to replace with, may be null
@return the text with any replacements processed,
null if null String input
@see #replace(String text, String repl, String with, int max)
public static String replace(String text, String repl, String with)
20、
Replaces a String with another String inside a larger String,
for the first max values of the search String.
A null reference passed to this method is a no-op.
以指定字符串最大替换原来字符串的的指定字符串
Java代码 收藏代码
StringUtils.replace(null, *, *, *) = null
StringUtils.replace("", *, *, *) = ""
StringUtils.replace("abaa", null, null, 1) = "abaa"
StringUtils.replace("abaa", null, null, 1) = "abaa"
StringUtils.replace("abaa", "a", null, 1) = "abaa"
StringUtils.replace("abaa", "a", "", 1) = "abaa"
StringUtils.replace("abaa", "a", "z", 0) = "abaa"
StringUtils.replace("abaa", "a", "z", 1) = "zbaa"
StringUtils.replace("abaa", "a", "z", 2) = "zbza"
StringUtils.replace("abaa", "a", "z", -1) = "zbzz"
@param text text to search and replace in, may be null
@param repl the String to search for, may be null
@param with the String to replace with, may be null
@param max maximum number of values to replace, or -1 if no maximum
@return the text with any replacements processed,
null if null String input
public static String replace(String text, String repl, String with, int max)
九、 Case conversion(大小写转换)
21、
Converts a String to upper case as per {@link String#toUpperCase()}.
A null input String returns null.
将一个字符串变为大写
Java代码 收藏代码
StringUtils.upperCase(null) = null
StringUtils.upperCase("") = ""
StringUtils.upperCase("aBc") = "ABC"
@param str the String to upper case, may be null
@return the upper cased String, null if null String input
public static String upperCase(String str)
22、
Converts a String to lower case as per {@link String#toLowerCase()}.
A null input String returns null.
将一个字符串转换为小写
Java代码 收藏代码
StringUtils.lowerCase(null) = null
StringUtils.lowerCase("") = ""
StringUtils.lowerCase("aBc") = "abc"
@param str the String to lower case, may be null
@return the lower cased String, null if null String input
public static String lowerCase(String str)
23、
Capitalizes a String changing the first letter to title case as
per {@link Character#toTitleCase(char)}. No other letters are changed.
For a word based alorithm, see {@link /WordUtils#capitalize(String)}.
A null input String returns null.
Java代码 收藏代码
StringUtils.capitalize(null) = null
StringUtils.capitalize("") = ""
StringUtils.capitalize("cat") = "Cat"
StringUtils.capitalize("cAt") = "CAt"
@param str the String to capitalize, may be null
@return the capitalized String, null if null String input
@see /WordUtils#capitalize(String)
@see /uncapitalize(String)
@since 2.0
// 将字符串中的首字母大写
public static String capitalize(String str)
StringUtil包函数
1.空字符串检查
使用函数: StringUtils.isBlank(testString)
函数介绍: 当testString为空,长度为零或者仅由空白字符(whitespace)组成时,返回True;否则返回False
例程:
Java代码 收藏代码
String test = "";
String test2 = "\n\n\t";
String test3 = null;
String test4 = "Test";
System.out.println( "test blank? " + StringUtils.isBlank( test ) );
System.out.println( "test2 blank? " + StringUtils.isBlank( test2 ) );
System.out.println( "test3 blank? " + StringUtils.isBlank( test3 ) );
System.out.println( "test4 blank? " + StringUtils.isBlank( test4 ) );
输出如下:
test blank? true
test2 blank? true
test3 blank? true
test4 blank? False
函数StringUtils.isNotBlank(testString)的功能与StringUtils.isBlank(testString)相反.
2.清除空白字符
使用函数: StringUtils.trimToNull(testString)
函数介绍:清除掉testString首尾的空白字符,如果仅testString全由空白字符
(whitespace)组成则返回null
例程:
Java代码 收藏代码
String test1 = "\t";
String test2 = " A Test ";
String test3 = null;
System.out.println( "test1 trimToNull: " + StringUtils.trimToNull( test1 ) );
System.out.println( "test2 trimToNull: " + StringUtils.trimToNull( test2 ) );
System.out.println( "test3 trimToNull: " + StringUtils.trimToNull( test3 ) );
输出如下:
test1 trimToNull: null
test2 trimToNull: A Test
test3 trimToNull: null
注意:函数StringUtils.trim(testString)与
StringUtils.trimToNull(testString)功能类似,但testString由空白字符
(whitespace)组成时返回零长度字符串。
3.取得字符串的缩写
使用函数: StringUtils.abbreviate(testString,width)和StringUtils.abbreviate(testString,offset,width)
函数介绍:在给定的width内取得testString的缩写,当testString的长度小于width则返回原字符串.
例程:
Java代码 收藏代码
String test = "This is a test of the abbreviation.";
String test2 = "Test";
System.out.println( StringUtils.abbreviate( test, 15 ) );
System.out.println( StringUtils.abbreviate( test, 5,15 ) );
System.out.println( StringUtils.abbreviate( test2, 10 ) );
输出如下:
This is a te...
...is a test...
Test
4.劈分字符串
使用函数: StringUtils.split(testString,splitChars,arrayLength)
函数介绍:splitChars中可以包含一系列的字符串来劈分testString,并可以设定得
到数组的长度.注意设定长度arrayLength和劈分字符串间有抵触关系,建议一般情况下
不要设定长度.
例程:
Java代码 收藏代码
String input = "A b,c.d|e";
String input2 = "Pharmacy, basketball funky";
String[] array1 = StringUtils.split(input, " ,.|");
String[] array2 = StringUtils.split(input2, " ,", 2);
System.out.println(ArrayUtils.toString(array1));
System.out.println(ArrayUtils.toString(array2));
输出如下:
{A,b,c,d,e}
{Pharmacy,basketball funky}
5.查找嵌套字符串
使用函数:StringUtils.substringBetween(testString,header,tail)
函数介绍:在testString中取得header和tail之间的字符串。不存在则返回空
例程:
Java代码 收藏代码
String htmlContent = "ABC1234ABC4567";
System.out.println(StringUtils.substringBetween(htmlContent, "1234", "4567"));
System.out.println(StringUtils.substringBetween(htmlContent, "12345", "4567"));
输出如下:
ABC
null
6.去除尾部换行符
使用函数:StringUtils.chomp(testString)
函数介绍:去除testString尾部的换行符
例程:
Java代码 收藏代码
String input = "Hello\n";
System.out.println(StringUtils.chomp(input));
String input2 = "Another test\r\n";
System.out.println(StringUtils.chomp(input2));
输出如下:
Hello
Another test
7.重复字符串
使用函数:StringUtils.repeat(repeatString,count)
函数介绍:得到将repeatString重复count次后的字符串
例程:
Java代码 收藏代码
System.out.println( StringUtils.repeat( "*", 10));
System.out.println( StringUtils.repeat( "China ", 5));
输出如下:
**********
China China China China China
其他函数:StringUtils.center( testString, count,repeatString );
函数介绍:把testString插入将repeatString重复多次后的字符串中间,得到字符串
的总长为count
例程:
Java代码 收藏代码
System.out.println( StringUtils.center( "China", 11,"*"));
输出如下:
***China***
8.颠倒字符串
使用函数:StringUtils.reverse(testString)
函数介绍:得到testString中字符颠倒后的字符串
例程:
Java代码 收藏代码
System.out.println( StringUtils.reverse("ABCDE"));
输出如下:
EDCBA
9.判断字符串内容的类型
函数介绍:
Java代码 收藏代码
StringUtils.isNumeric( testString ) //如果testString全由数字组成返回True
StringUtils.isAlpha( testString ) //如果testString全由字母组成返回True
StringUtils.isAlphanumeric( testString ) //如果testString全由数字或数字组
成返回True
Java代码 收藏代码
StringUtils.isAlphaspace( testString ) //如果testString全由字母或空格组
成返回True
例程:
Java代码 收藏代码
String state = "Virginia";
System.out.println("Is state number? " + StringUtils.isNumeric(state));
System.out.println("Is state alpha? " + StringUtils.isAlpha(state));
System.out.println("Is state alphanumeric? " + StringUtils.isAlphanumeric(state));
System.out.println("Is state alphaspace? " + StringUtils.isAlphaSpace(state));
输出如下:
Is state number? false
Is state alpha? true
Is state alphanumeric? true
Is state alphaspace? true
10.取得某字符串在另一字符串中出现的次数
使用函数:StringUtils.countMatches(testString,seqString)
函数介绍:取得seqString在testString中出现的次数,未发现则返回零
例程:
Java代码 收藏代码
System.out.println(StringUtils.countMatches( "Chinese People", "e"
));
输出:
4
11.部分截取字符串
使用函数:
Java代码 收藏代码
StringUtils.substringBetween(testString,fromString,toString )//取得两字符之间的字符串
StringUtils.substringAfter( )//取得指定字符串后的字符串
StringUtils.substringBefore( )//取得指定字符串之前的字符串
StringUtils.substringBeforeLast( )//取得最后一个指定字符串之前的字符串
StringUtils.substringAfterLast( )//取得最后一个指定字符串之后的字符串
函数介绍:上面应该都讲明白了吧。
例程:
Java代码 收藏代码
String formatted = " 25 * (30,40) [50,60] | 30";
System.out.print("N0: " + StringUtils.substringBeforeLast(formatted, "*"));
System.out.print(", N1: " + StringUtils.substringBetween(formatted, "(", ","));
System.out.print(", N2: " + StringUtils.substringBetween(formatted, ",", ")"));
System.out.print(", N3: " + StringUtils.substringBetween(formatted, "[", ","));
System.out.print(", N4: " + StringUtils.substringBetween(formatted, ",", "]"));
System.out.print(", N5: " + StringUtils.substringAfterLast(formatted, "|"));
输出如下:
N0: 25 , N1: 30, N2: 40, N3: 50, N4: 40) [50,60, N5: 30
---------------------------------------------------------------------------------------------------------------------------------------
一、数组转成字符串:
1、 将数组中的字符转换为一个字符串
将数组中的字符转换为一个字符串
Java代码 收藏代码
@param strToConv 要转换的字符串 ,默认以逗号分隔
@return 返回一个字符串
String[3] s={"a","b","c"}
StringUtil.convString(s)="a,b,c"
2、
Java代码 收藏代码
static public String converString(String strToConv)
@param strToConv 要转换的字符串 ,
@param conv 分隔符,默认以逗号分隔
@return 同样返回一个字符串
String[3] s={"a","b","c"}
StringUtil.convString(s,"@")="a@b@c"
static public String converString(String strToConv, String conv)
二、空值检测:
3、
Java代码 收藏代码
Checks if a String is empty ("") or null.
判断一个字符串是否为空,空格作非空处理。
Java代码 收藏代码
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0.
It no longer trims the String.
That functionality is available in isBlank().
Java代码 收藏代码
@param str the String to check, may be null
@return true if the String is empty or null
public static boolean isEmpty(String str)
三、非空处理:
4、
Checks if a String is not empty ("") and not null.
判断一个字符串是否非空,空格作非空处理.
Java代码 收藏代码
StringUtils.isNotEmpty(null) = false
StringUtils.isNotEmpty("") = false
StringUtils.isNotEmpty(" ") = true
StringUtils.isNotEmpty("bob") = true
StringUtils.isNotEmpty(" bob ") = true
@param str the String to check, may be null
@return true if the String is not empty and not null
public static boolean isNotEmpty(String str)
5、
Checks if a String is not empty (""), not null and not whitespace only.
判断一个字符串是否非空,空格作空处理.
Java代码 收藏代码
StringUtils.isNotBlank(null) = false
StringUtils.isNotBlank("") = false
StringUtils.isNotBlank(" ") = false
StringUtils.isNotBlank("bob") = true
StringUtils.isNotBlank(" bob ") = true
@param str the String to check, may be null
@return true if the String is not empty and not null and not whitespace
@since 2.0
public static boolean isNotBlank(String str)
四、 空格处理
6、
Removes control characters (char <= 32) from both
ends of this String, handling null by returning
null.
The String is trimmed using {@link String#trim()}.
Trim removes start and end characters <= 32.
To strip whitespace use {@link //strip(String)}.
To trim your choice of characters, use the
{@link //strip(String, String)} methods.
格式化一个字符串中的空格,有非空判断处理;
Java代码 收藏代码
StringUtils.trim(null) = null
StringUtils.trim("") = ""
StringUtils.trim(" ") = ""
StringUtils.trim("abc") = "abc"
StringUtils.trim(" abc ") = "abc"
@param str the String to be trimmed, may be null
@return the trimmed string, null if null String input
public static String trim(String str)
7、
Removes control characters (char <= 32) from both
ends of this String returning null if the String is
empty ("") after the trim or if it is null.
The String is trimmed using {@link String#trim()}.
Trim removes start and end characters <= 32.
To strip whitespace use {@link /stripToNull(String)}.
格式化一个字符串中的空格,有非空判断处理,如果为空返回null;
Java代码 收藏代码
StringUtils.trimToNull(null) = null
StringUtils.trimToNull("") = null
StringUtils.trimToNull(" ") = null
StringUtils.trimToNull("abc") = "abc"
StringUtils.trimToNull(" abc ") = "abc"
@param str the String to be trimmed, may be null
@return the trimmed String,
null if only chars <= 32, empty or null String input
@since 2.0
public static String trimToNull(String str)
8、
Removes control characters (char <= 32) from both
ends of this String returning an empty String ("") if the String
is empty ("") after the trim or if it is null.
The String is trimmed using {@link String#trim()}.
Trim removes start and end characters <= 32.
To strip whitespace use {@link /stripToEmpty(String)}.
格式化一个字符串中的空格,有非空判断处理,如果为空返回"";
Java代码 收藏代码
StringUtils.trimToEmpty(null) = ""
StringUtils.trimToEmpty("") = ""
StringUtils.trimToEmpty(" ") = ""
StringUtils.trimToEmpty("abc") = "abc"
StringUtils.trimToEmpty(" abc ") = "abc"
@param str the String to be trimmed, may be null
@return the trimmed String, or an empty String if null input
@since 2.0
public static String trimToEmpty(String str)
五、 字符串比较:
9、
Compares two Strings, returning true if they are equal.
nulls are handled without exceptions. Two null
references are considered to be equal. The comparison is case sensitive.
判断两个字符串是否相等,有非空处理。
Java代码 收藏代码
StringUtils.equals(null, null) = true
StringUtils.equals(null, "abc") = false
StringUtils.equals("abc", null) = false
StringUtils.equals("abc", "abc") = true
StringUtils.equals("abc", "ABC") = false
@param str1 the first String, may be null
@param str2 the second String, may be null
@return true if the Strings are equal, case sensitive, or
both null
@see java.lang.String#equals(Object)
public static boolean equals(String str1, String str2)
10、
Compares two Strings, returning true if they are equal ignoring
the case.
nulls are handled without exceptions. Two null
references are considered equal. Comparison is case insensitive.
判断两个字符串是否相等,有非空处理。忽略大小写
Java代码 收藏代码
StringUtils.equalsIgnoreCase(null, null) = true
StringUtils.equalsIgnoreCase(null, "abc") = false
StringUtils.equalsIgnoreCase("abc", null) = false
StringUtils.equalsIgnoreCase("abc", "abc") = true
StringUtils.equalsIgnoreCase("abc", "ABC") = true
@param str1 the first String, may be null
@param str2 the second String, may be null
@return true if the Strings are equal, case insensitive, or
both null
@see java.lang.String#equalsIgnoreCase(String)
public static boolean equalsIgnoreCase(String str1, String str2)
六、 IndexOf 处理
11、
Finds the first index within a String, handling null.
This method uses {@link String#indexOf(String)}.
A null String will return -1.
返回要查找的字符串所在位置,有非空处理
Java代码 收藏代码
StringUtils.indexOf(null, *) = -1
StringUtils.indexOf(*, null) = -1
StringUtils.indexOf("", "") = 0
StringUtils.indexOf("aabaabaa", "a") = 0
StringUtils.indexOf("aabaabaa", "b") = 2
StringUtils.indexOf("aabaabaa", "ab") = 1
StringUtils.indexOf("aabaabaa", "") = 0
@param str the String to check, may be null
@param searchStr the String to find, may be null
@return the first index of the search String,
-1 if no match or null string input
@since 2.0
public static int indexOf(String str, String searchStr)
12、
Finds the first index within a String, handling null.
This method uses {@link String#indexOf(String, int)}.
A null String will return -1.
A negative start position is treated as zero.
An empty ("") search String always matches.
A start position greater than the string length only matches
an empty search String.
返回要由指定位置开始查找的字符串所在位置,有非空处理
Java代码 收藏代码
StringUtils.indexOf(null, *, *) = -1
StringUtils.indexOf(*, null, *) = -1
StringUtils.indexOf("", "", 0) = 0
StringUtils.indexOf("aabaabaa", "a", 0) = 0
StringUtils.indexOf("aabaabaa", "b", 0) = 2
StringUtils.indexOf("aabaabaa", "ab", 0) = 1
StringUtils.indexOf("aabaabaa", "b", 3) = 5
StringUtils.indexOf("aabaabaa", "b", 9) = -1
StringUtils.indexOf("aabaabaa", "b", -1) = 2
StringUtils.indexOf("aabaabaa", "", 2) = 2
StringUtils.indexOf("abc", "", 9) = 3
@param str the String to check, may be null
@param searchStr the String to find, may be null
@param startPos the start position, negative treated as zero
@return the first index of the search String, -1 if no match or null string input
@since 2.0
public static int indexOf(String str, String searchStr, int startPos)
七、 子字符串处理:
13、
Gets a substring from the specified String avoiding exceptions.
A negative start position can be used to start n
characters from the end of the String.
A null String will return null.
An empty ("") String will return "".
返回指定位置开始的字符串中的所有字符
Java代码 收藏代码
StringUtils.substring(null, *) = null
StringUtils.substring("", *) = ""
StringUtils.substring("abc", 0) = "abc"
StringUtils.substring("abc", 2) = "c"
StringUtils.substring("abc", 4) = ""
StringUtils.substring("abc", -2) = "bc"
StringUtils.substring("abc", -4) = "abc"
@param str the String to get the substring from, may be null
@param start the position to start from, negative means
count back from the end of the String by this many characters
@return substring from start position, null if null String input
public static String substring(String str, int start)
14、
Gets a substring from the specified String avoiding exceptions.
A negative start position can be used to start/end n
characters from the end of the String.
The returned substring starts with the character in the start
position and ends before the end position. All postion counting is
zero-based -- i.e., to start at the beginning of the string use
start = 0. Negative start and end positions can be used to
specify offsets relative to the end of the String.
If start is not strictly to the left of end, ""
is returned.
返回由开始位置到结束位置之间的子字符串
Java代码 收藏代码
StringUtils.substring(null, *, *) = null
StringUtils.substring("", * , *) = "";
StringUtils.substring("abc", 0, 2) = "ab"
StringUtils.substring("abc", 2, 0) = ""
StringUtils.substring("abc", 2, 4) = "c"
StringUtils.substring("abc", 4, 6) = ""
StringUtils.substring("abc", 2, 2) = ""
StringUtils.substring("abc", -2, -1) = "b"
StringUtils.substring("abc", -4, 2) = "ab"
@param str the String to get the substring from, may be null
@param start the position to start from, negative means
count back from the end of the String by this many characters
@param end the position to end at (exclusive), negative means
count back from the end of the String by this many characters
@return substring from start position to end positon,
null if null String input
public static String substring(String str, int start, int end)
15、 SubStringAfter/SubStringBefore(前后子字符串处理:
Gets the substring before the first occurance of a separator.
The separator is not returned.
A null string input will return null.
An empty ("") string input will return the empty string.
A null separator will return the input string.
返回指定字符串之前的所有字符
Java代码 收藏代码
StringUtils.substringBefore(null, *) = null
StringUtils.substringBefore("", *) = ""
StringUtils.substringBefore("abc", "a") = ""
StringUtils.substringBefore("abcba", "b") = "a"
StringUtils.substringBefore("abc", "c") = "ab"
StringUtils.substringBefore("abc", "d") = "abc"
StringUtils.substringBefore("abc", "") = ""
StringUtils.substringBefore("abc", null) = "abc"
@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring before the first occurance of the separator,
null if null String input
@since 2.0
public static String substringBefore(String str, String separator)
16、
Gets the substring after the first occurance of a separator.
The separator is not returned.
A null string input will return null.
An empty ("") string input will return the empty string.
A null separator will return the empty string if the
input string is not null.
返回指定字符串之后的所有字符
Java代码 收藏代码
StringUtils.substringAfter(null, *) = null
StringUtils.substringAfter("", *) = ""
StringUtils.substringAfter(*, null) = ""
StringUtils.substringAfter("abc", "a") = "bc"
StringUtils.substringAfter("abcba", "b") = "cba"
StringUtils.substringAfter("abc", "c") = ""
StringUtils.substringAfter("abc", "d") = ""
StringUtils.substringAfter("abc", "") = "abc"
@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring after the first occurance of the separator,
null if null String input
@since 2.0
public static String substringAfter(String str, String separator)
17、
Gets the substring before the last occurance of a separator.
The separator is not returned.
A null string input will return null.
An empty ("") string input will return the empty string.
An empty or null separator will return the input string.
返回最后一个指定字符串之前的所有字符
Java代码 收藏代码
StringUtils.substringBeforeLast(null, *) = null
StringUtils.substringBeforeLast("", *) = ""
StringUtils.substringBeforeLast("abcba", "b") = "abc"
StringUtils.substringBeforeLast("abc", "c") = "ab"
StringUtils.substringBeforeLast("a", "a") = ""
StringUtils.substringBeforeLast("a", "z") = "a"
StringUtils.substringBeforeLast("a", null) = "a"
StringUtils.substringBeforeLast("a", "") = "a"
@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring before the last occurance of the separator,
null if null String input
@since 2.0
public static String substringBeforeLast(String str, String separator)
18、
Gets the substring after the last occurance of a separator.
The separator is not returned.
A null string input will return null.
An empty ("") string input will return the empty string.
An empty or null separator will return the empty string if
the input string is not null.
返回最后一个指定字符串之后的所有字符
Java代码 收藏代码
StringUtils.substringAfterLast(null, *) = null
StringUtils.substringAfterLast("", *) = ""
StringUtils.substringAfterLast(*, "") = ""
StringUtils.substringAfterLast(*, null) = ""
StringUtils.substringAfterLast("abc", "a") = "bc"
StringUtils.substringAfterLast("abcba", "b") = "a"
StringUtils.substringAfterLast("abc", "c") = ""
StringUtils.substringAfterLast("a", "a") = ""
StringUtils.substringAfterLast("a", "z") = ""
@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring after the last occurance of the separator,
null if null String input
@since 2.0
public static String substringAfterLast(String str, String separator)
八、 Replacing(字符串替换)
19、
Replaces all occurances of a String within another String.
A null reference passed to this method is a no-op.
以指定字符串替换原来字符串的的指定字符串
Java代码 收藏代码
StringUtils.replace(null, *, *) = null
StringUtils.replace("", *, *) = ""
StringUtils.replace("aba", null, null) = "aba"
StringUtils.replace("aba", null, null) = "aba"
StringUtils.replace("aba", "a", null) = "aba"
StringUtils.replace("aba", "a", "") = "aba"
StringUtils.replace("aba", "a", "z") = "zbz"
@param text text to search and replace in, may be null
@param repl the String to search for, may be null
@param with the String to replace with, may be null
@return the text with any replacements processed,
null if null String input
@see #replace(String text, String repl, String with, int max)
public static String replace(String text, String repl, String with)
20、
Replaces a String with another String inside a larger String,
for the first max values of the search String.
A null reference passed to this method is a no-op.
以指定字符串最大替换原来字符串的的指定字符串
Java代码 收藏代码
StringUtils.replace(null, *, *, *) = null
StringUtils.replace("", *, *, *) = ""
StringUtils.replace("abaa", null, null, 1) = "abaa"
StringUtils.replace("abaa", null, null, 1) = "abaa"
StringUtils.replace("abaa", "a", null, 1) = "abaa"
StringUtils.replace("abaa", "a", "", 1) = "abaa"
StringUtils.replace("abaa", "a", "z", 0) = "abaa"
StringUtils.replace("abaa", "a", "z", 1) = "zbaa"
StringUtils.replace("abaa", "a", "z", 2) = "zbza"
StringUtils.replace("abaa", "a", "z", -1) = "zbzz"
@param text text to search and replace in, may be null
@param repl the String to search for, may be null
@param with the String to replace with, may be null
@param max maximum number of values to replace, or -1 if no maximum
@return the text with any replacements processed,
null if null String input
public static String replace(String text, String repl, String with, int max)
九、 Case conversion(大小写转换)
21、
Converts a String to upper case as per {@link String#toUpperCase()}.
A null input String returns null.
将一个字符串变为大写
Java代码 收藏代码
StringUtils.upperCase(null) = null
StringUtils.upperCase("") = ""
StringUtils.upperCase("aBc") = "ABC"
@param str the String to upper case, may be null
@return the upper cased String, null if null String input
public static String upperCase(String str)
22、
Converts a String to lower case as per {@link String#toLowerCase()}.
A null input String returns null.
将一个字符串转换为小写
Java代码 收藏代码
StringUtils.lowerCase(null) = null
StringUtils.lowerCase("") = ""
StringUtils.lowerCase("aBc") = "abc"
@param str the String to lower case, may be null
@return the lower cased String, null if null String input
public static String lowerCase(String str)
23、
Capitalizes a String changing the first letter to title case as
per {@link Character#toTitleCase(char)}. No other letters are changed.
For a word based alorithm, see {@link /WordUtils#capitalize(String)}.
A null input String returns null.
Java代码 收藏代码
StringUtils.capitalize(null) = null
StringUtils.capitalize("") = ""
StringUtils.capitalize("cat") = "Cat"
StringUtils.capitalize("cAt") = "CAt"
@param str the String to capitalize, may be null
@return the capitalized String, null if null String input
@see /WordUtils#capitalize(String)
@see /uncapitalize(String)
@since 2.0
// 将字符串中的首字母大写
public static String capitalize(String str)
发表评论
-
nginx proxy_pass斜杠
2021-08-19 17:57 679收到的请求统一为 http:/ ... -
centos8 安装puppeteer
2020-05-23 22:36 719在用centos8安装puppeteer过程中遇到了不少的坑 ... -
关于jenkins搭建
2018-07-19 18:17 506java -Dfile.encoding=UTF8 -jar ... -
Server Tomcat v6.0 Server at localhost was unable to start within 45 seconds
2014-09-10 17:01 1193错误 Server Tomcat v6.0 Server at ... -
maven学习
2012-03-12 00:12 8851.初识maven,参考附件。 -
关于spring事务传播行为和隔离级别
2012-02-17 11:30 950转自:http://tech.it168.com/j/ ... -
urlrewrite
2011-12-25 00:06 11691.下载urlrewrite-3.2.0.jar放入lib包并 ... -
winows下安装apache+php+mysql
2011-12-11 18:04 1057win+apache+php+mysql环境配置 2007-0 ... -
tomcat性能调优
2011-11-14 11:44 478Tomcat性能调优方案(原文地址http://16.199. ... -
proxool连接池
2011-11-09 16:21 937转载自http://www.blogjava.ne ... -
springMVC框架学习备份
2011-10-20 17:36 1036springMVC框架学习备份 -
spring编码过滤器
2011-10-12 11:17 1270由于编码的不一致,我们可以在web.xml中配置spring的 ... -
spring中quartz配置文件
2011-08-15 11:12 22271.下面是spring中的quartz配置文件的备份,以备参考 ... -
java.net.BindException: Cannot assign requested address
2011-07-22 09:48 1510ava.net.BindException: Cannot a ... -
xfire中wsdl中参数的友好化
2011-07-20 17:45 1626需求: 使用xfire开发webservice过程中 ... -
spring学习
2010-08-10 10:53 998转载: http://www.iteye.com/wik ... -
FileUtils
2010-03-26 17:13 1093上传组件可以使用apache的上传组件 org.apache. ... -
struts2上传文件类型限制
2010-03-22 09:57 2658'.a' : 'application/octet- ... -
thread dump
2010-02-22 18:26 1019使用kill -3 tomcat的pid号 可以得到tomca ... -
了解一下如何架设流媒体服务器
2009-12-17 09:48 2036本文转载自http://www.bluei ...
相关推荐
本项目名为"C语言实现String字符串及其函数stringUtil",主要关注的是如何在C语言环境中自定义处理字符串的函数,以扩展标准库中提供的功能。通过分析`stringUtil.c`源代码和`stringUtil.h`头文件,我们可以了解一些...
首先,`StringUtil.cpp`和`StringUtil.h`是C++中的源代码文件和头文件,它们定义了类`StringUtil`及其成员函数。在C++中,头文件通常用于声明类、函数、常量等,而源代码文件则包含了这些声明的实现细节。在这个案例...
"AS3-StringUtil"就是这样一款专门用于AS3字符串处理的工具库,它提供了一系列高效、实用的字符串操作函数,旨在简化开发过程。 在深入解析AS3-StringUtil之前,我们需要了解AS3的基本语法和字符串处理的相关知识。...
在Go语言中,`stringutil`通常是指一个自定义的包,包含了一些对字符串操作的实用函数,以方便开发者处理日常编程中的字符串问题。这个标题"stringutil:一些Go字符串实用程序"暗示了我们可能有一个名为`stringutil`...
Java.util包是Java标准库中的核心包之一,包含了许多用于处理集合、数组、日期时间、随机数等的类。在本文件中,我们主要关注Java.util.ArrayList类,这是一个常用的动态数组实现,它提供了灵活的大小调整和高效的...
Jodd = Tools IoC MVC DB AOP TX JSON HTML < 1.5 MbJodd 被分成众多模块,按需选择,其中工具类模块有:jodd-core 一些工具类,包括Printf、JDateTime、StringUtil、Fast buffers等等jodd-bean BeanUtil以及类型...
Java util包使用详解 Java util包是Java语言中一个实用的工具类库,提供了许多有用的方法和数据结构。下面将逐一介绍其中几个重要的类。 日期类Date Java中的日期类封装了有关日期和时间的信息,用户可以通过调用...
`c++ 字符串分割util`通常指的是一个自定义的函数或类库,用于将字符串按照特定的分隔符进行切割,生成一个字符串向量或者数组。在C++标准库中,虽然没有直接提供类似Python的`split()`函数,但我们可以利用其他工具...
### 标题:util包里的Date类转换为sql包里的Date #### 了解util包里的Date类 `java.util.Date`是Java标准库中的一个类,用于表示特定的时间点,精确到毫秒。这个类提供了多种构造函数来创建日期对象,并且还提供了...
Util.js 是一个非常实用的JavaScript库,它封装了一系列常见的功能函数,旨在简化开发过程,提高代码的可复用性和效率。这个库涵盖了多种类别,包括处理数组、浏览器特性、日期操作、函数辅助、数学计算、媒体操作、...
类似于`printf`或`format`函数,`StringUtil.format(String format, Object... args)`方法可以用于构建动态字符串。它可以接受一个格式字符串和任意数量的参数,将参数按照格式字符串中的占位符替换进去。 5. **...
在这个主题中,我们将深入探讨`StringUtil`、`FileUtil`、`MD5`、`JsonUtil`以及`ObjectUtil`这五个关键工具类的使用和功能。 首先,`StringUtil`通常是自定义或第三方库中用于处理字符串的工具类。它包含了对字符...
### Java_util 工具包详解 #### 一、引言 `java.util`包作为Java标准库中的一个重要组成部分,提供了大量的实用工具类和接口,旨在简化开发者在处理数据结构、日期时间、事件处理等方面的工作。这个包包含了如日期...
标题提到的"base64包,decodeBase64包,encodeBase64String包"可能是指Java编程语言中的相关库或模块。在Java中,Base64编码和解码通常通过`java.util.Base64`类来实现。这个类提供了几个不同的子类和方法,用于处理...
Java.util 包详细讲解 Java.util 包是 Java 语言中一个非常实用的工具类库,提供了一些实用的方法和数据结构。下面我们将详细讲解 Java.util 包中的重要类和方法。 1. 日期类 Date 日期类 Date 是 Java.util 包中...
Java的`java.util.zip`包提供了解压缩和创建ZIP文件的功能,例如`ZipOutputStream`用于创建ZIP文件,`ZipInputStream`用于读取ZIP文件。可能的方法有`compressFile()`压缩单个文件,`unzipFile()`解压文件等。 4. *...
在给定的`UtilClass`中,我们有五个主要的工具类:`StringUtil`、`FileUtil`、`ConnectDB`、`DateUtil`和`TimeUtil`。这些类分别专注于字符串操作、文件处理、数据库连接、日期和时间管理。接下来,我们将详细探讨每...
<function-signature>java.lang.String formatDate(java.util.Date, java.lang.String) ``` 在这个TLD文件中,我们指定了函数的名称、类名以及函数的完整签名。`function-class`是包含函数的类全名,`function-...
Commons Lang是Apache软件基金会开发的一个Java工具包,它提供了许多实用的函数,扩展了Java标准库中关于字符串处理的功能。`StringUtils`类是这个工具包中的核心类之一,专门用于处理字符串的各种操作,包括但不...
"卡拉OK表字段.doc"可能涉及数据库设计,而"Util.js"可能是JavaScript的实用工具库,与Java的构造函数和析构函数主题关系不大。 总的来说,理解和掌握构造函数、析构函数(以及在Java中的`finalize()`方法)、函数...