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();
    }
}

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

猜你喜欢

转载自blog.csdn.net/qq_42685333/article/details/87930432