1.TextUtils.isEmpty
Returns true if the string is null or 0-length.
2.FileUtils.deleteDir(file)
Deletes all files and subdirectories under "dir".
3.
HashMap不支持线程的同步
Hashmap 是一个最常用的Map,它根据键的HashCode值存储数据,根据键可以直接获取它的值,具有很快的访问速度,遍历时,取得数据的顺序是完全随机的。 HashMap最多只允许一条记录的键为Null;允许多条记录的值为 Null;HashMap不支持线程的同步,即任一时刻可以有多个线程同时写HashMap;可能会导致数据的不一致。如果需要同步,可以用 Collections的synchronizedMap方法使HashMap具有同步的能力,或者使用ConcurrentHashMap。
Hashtable 同步
Hashtable与 HashMap类似,它继承自Dictionary类,不同的是:它不允许记录的键或者值为空;它支持线程的同步,即任一时刻只有一个线程能写Hashtable,因此也导致了 Hashtable在写入时会比较慢。
4 判断是否为数字
public static boolean isNumeric(String str) {
return isMatcher(
"[0-9]*",
str);
}
5 判断是否是邮箱格式
public static boolean checkEmail(String str) {
return isMatcher(
"^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$",
str);
}
6.判断是否是手机号码
public static boolean checkMobile(String str) {
// String regex = "^1(3[0-9]|5[012356789]|8[0789])\\d{8}$";
return isMatcher(
"^((13[0-9])|(147)|(15[^4,\\D])|(18[0,5-9]))\\d{8}$",
str);
}
7.查找字符
private static boolean isMatcher(String regex, String str){
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(str);
return m.find();
}
来源:https://www.cnblogs.com/starblogs/archive/2013/03/26/2983044.html