/** * 将对象转为字符串:为空,则返回空字符串;而不是"null" * @param pObj 为空,则返回空字符串 * @return */ public static String toString(Object pObj) { String str = ""; if(pObj!=null) { str = pObj.toString(); } return str; }
public static boolean isNullOrEmpty(String pStr){ boolean vIsOK = true; if(pStr!=null && !pStr.trim().equals("")){ vIsOK = false; } return vIsOK; } public static String dealString(String pStr){ if(isNullOrEmpty(pStr)){ return ""; } else{ return pStr.trim(); } } public static String dealStringAllowNull(String pStr){ if(isNullOrEmpty(pStr)){ return null; } else{ return pStr.trim(); } }