package com.codebase.util; /** * @describe: String manipulation tool class * @author:houkai * @Date: 2018/4/4 11:00 */ public class StringUtil { /** * Whether the string is empty, including blank * @param str * @return */ public static boolean isNullOrEmpty(String str){ return null != str && 0 != str.trim().length() ? false : true ; } /** * Determine if it is empty * @param str * @return */ public static boolean isEmpty(String str){ if (str== null || "" .equals(str.trim())){ return true ; }else{ return false; } } /** * Check if the string is blank: null, empty string "" character. * StringUtil.isBlank(null) = true * StringUtil.isBlank("") = true * StringUtil.isBlank(" ") = true * StringUtil.isBlank("bob") = false * StringUtil.isBlank(" bob ") = false * @param str String to check for * @return true if blank */ public static boolean isBlank(String str) { int length; if ((str == null ) || ((length = str. length()) == 0 )) { return true ; } for (int i = 0; i < length; i++) { if (!Character.isWhitespace(str.charAt(i))) { return false; } } return true; } /** * Check if the string is not whitespace: null, the empty string "", or just whitespace characters. * StringUtil.isBlank(null) = false * StringUtil.isBlank("") = false * StringUtil.isBlank(" ") = false * StringUtil.isBlank("bob") = true * StringUtil.isBlank(" bob ") = true * @param str String to check for * @return true if blank */ public static boolean isNotBlank(String str) { int length; if ((str == null ) || ((length = str. length()) == 0 )) { return false ; } for (int i = 0; i < length; i++) { if (!Character.isWhitespace(str.charAt(i))) { return true; } } return false; } }
String manipulation tools
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325442756&siteId=291194637
Recommended
Ranking