1.Commons Lang
1.1 org.apache.commons.lang.ClassUtils;
1.2 org.apache.commons.lang.ArrayUtils;
//判斷基本數(shù)據(jù)類型或者對(duì)象數(shù)組中是否包含這個(gè)元素
ArrayUtils.contains();
1.3 org.apache.commons.lang.ObjectUtils;
//ObjectUtils的toString方法
public static String toString(Object obj) {
return obj == null ? "" : obj.toString();
}
org.apache.commons.lang.StringUtils;
//ObjectUtils的方法isBlank,null或者無內(nèi)容或者有內(nèi)容但是是一堆空格都返回true
public static boolean isBlank(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if ((Character.isWhitespace(str.charAt(i)) == false)) {
return false;
}
}
return true;
}
org.apache.commons.lang.math.NumberUtils;
NumberUtils.inNumber(String) 他會(huì)正確判斷出給定的字符串是否是合法的數(shù)值?????
而 StringUtils.isNumeric(String 只能判斷一個(gè)字符串是否是由純數(shù)字字符組成
org.apache.commons.chain.Chain;
/**saveOrUpdateChain 保存責(zé)任鏈*/
@Autowired
@Qualifier("saveOrUpdateChain")
private Chain saveOrUpdateChain;
org.apache.commons.chain.Command;
org.apache.commons.chain.Context;
org.apache.commons.collections.CollectionUtils;
//在集合為null以及沒有內(nèi)容的情況下均返回true
CollectionUtils.isEmpty(jzBeanList);
org.apache.commons.lang.ClassUtils;
org.apache.commons.lang.ArrayUtils;
//判斷基本數(shù)據(jù)類型或者對(duì)象數(shù)組中是否包含這個(gè)元素
ArrayUtils.contains();
org.apache.commons.lang.ObjectUtils;
//ObjectUtils的toString方法
public static String toString(Object obj) {
return obj == null ? "" : obj.toString();
}
org.apache.commons.lang.StringUtils;
//ObjectUtils的方法isBlank,null或者無內(nèi)容或者有內(nèi)容但是是一堆空格都返回true
public static boolean isBlank(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if ((Character.isWhitespace(str.charAt(i)) == false)) {
return false;
}
}
return true;
}
org.apache.commons.lang.math.NumberUtils;
NumberUtils.inNumber(String) 他會(huì)正確判斷出給定的字符串是否是合法的數(shù)值?????
而 StringUtils.isNumeric(String 只能判斷一個(gè)字符串是否是由純數(shù)字字符組成
org.apache.commons.logging.Log;
org.apache.commons.logging.LogFactory;
/**
* logger
*/
private Log logger = LogFactory.getLog(this.getClass());
org.apache.commons.io.IOUtils;
//長(zhǎng)用此類去關(guān)閉流
IOUtils.closeQuietly(is);
org.apache.commons.io.input.ClosedInputStream; ?????
public void close() throws IOException {
IOUtils.closeQuietly(in);
in = new ClosedInputStream();
}
org.apache.commons.io.FilenameUtils;
//獲取文件的后綴
String suffix = FilenameUtils.getExtension(tmpName);
org.apache.commons.beanutils.PropertyUtils;
//把后者的屬性賦給前者
PropertyUtils.copyProperties(treeNode, treeNodeDubbo);
org.apache.commons.codec.binary.Base64;
Base64類最主要的兩個(gè)靜態(tài)方法是:Base64.encodeBase64(byte[]byteArray),用于對(duì)字節(jié)數(shù)組中指定的內(nèi)容進(jìn)行執(zhí)行Base64編碼;
Base64.decodeBase64(byte[]byteArray),用于對(duì)字節(jié)數(shù)組中指定的內(nèi)容執(zhí)行Base64解碼。
另外,Base64還有一個(gè)靜態(tài)方法Base64.isArrayByteBase64(byte[] byteArray),用于檢測(cè)指定的字節(jié)數(shù)組是否可通過Base64測(cè)試(
即是否包含了經(jīng)過Base64編碼的數(shù)據(jù))。
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
org.apache.commons.httpclient.params.HttpMethodParams;
org.apache.commons.httpclient.HttpStatus;
org.apache.commons.httpclient.HttpException;
Commons-HttpClient 提供了可以工作于HTTP協(xié)議客戶端的一個(gè)框架.
org.apache.commons.lang.time.DateFormatUtils;
org.apache.commons.collections.map.CaseInsensitiveMap;
//獲得request中的header 由于header是不區(qū)分大小寫的,所有返回的headers是CaseInsensitiveMap
Map<String, String> headers = new CaseInsensitiveMap();
org.apache.commons.collections.MapUtils;
MapUtils.isEmpty(ctb.getIndexMap());
//MapUtils的isEmpty 方法
public static boolean isEmpty(Map map) {
return (map == null || map.isEmpty());
}
org.apache.commons.collections.map.LRUMap;
//用于構(gòu)建緩存或者連接池
private static final LRUMap EVENT_MAP = new LRUMap(100);
org.apache.commons.collections.map.ListOrderedMap;
//將一個(gè)HashMap初始化成一個(gè)有序的Map
Map<String, List<String>> dsrMcSsdwMap = ListOrderedMap.decorate(new HashMap<String, List<String>>());