分类:
2008-09-10 10:06:24
一、数组转成字符串:
1、 将数组中的字符转换为一个字符串
将数组中的字符转换为一个字符串
@param strToConv 要转换的字符串 ,默认以逗号分隔
@return 返回一个字符串
String[3] s={"a","b","c"}
StringUtil.convString(s)="a,b,c"
2、 static public String converString(String strToConv)
@param strToConv 要转换的字符串 ,
@param conv 分隔符,默认以逗号分隔
@return 同样返回一个字符串
String[3] s={"a","b","c"}
StringUtil.convString(s,"@")=""
static public String converString(String strToConv, String conv)
二、空值检测:
3、
Checks if a String is empty ("") or null.
判断一个字符串是否为空,空格作非空处理。 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().
@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.
判断一个字符串是否非空,空格作非空处理. 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.
判断一个字符串是否非空,空格作空处理. 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 String#trim()}.
Trim removes start and end characters <= 32.
To strip whitespace use //strip(String)}.
To trim your choice of characters, use the
//strip(String, String)} methods.
格式化一个字符串中的空格,有非空判断处理; 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 String#trim()}.
Trim removes start and end characters <= 32.
To strip whitespace use /stripToNull(String)}.
格式化一个字符串中的空格,有非空判断处理,如果为空返回null; 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 String#trim()}.
Trim removes start and end characters <= 32.
To strip whitespace use /stripToEmpty(String)}.
格式化一个字符串中的空格,有非空判断处理,如果为空返回""; 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)
[1]