Java字符串空与过滤处理

原文详解:Java字符串空与过滤处理
原文链接: http://licocom.com/archives/1162

常用java字符串空处理,与字符串空过滤处理
/**
 * 判断是否是空字符串 null和"" 都返回 true
 * @author
 * @param s
 * @return
 */
public static boolean isEmpty(String s) {
    if (s != null && !s.equals("")) {
        return false;
    }
    return true;
}

/**
 * 转化为String时过滤空
 * @param o
 * @return
 */
public static String formatEmpty(Object o){
    if(o == null){
        return "";
    }else{
        return o.toString();
    }
}

面向需求开发,记录学习之路。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章