All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hn.pay.wxpay.utils.StrKit Maven / Gradle / Ivy

There is a newer version: 1.0.18
Show newest version
package com.hn.pay.wxpay.utils;

/**
 * StrKit.
 */
public class StrKit {

	/**
	 * 字符串为 null 或者内部字符全部为 ' ' '\t' '\n' '\r' 这四类字符时返回 true
     * @param str str
	 * @return boolean
	 */
	public static boolean isBlank(String str) {
		if (str == null) {
			return true;
		}
		int len = str.length();
		if (len == 0) {
			return true;
		}
		for (int i = 0; i < len; i++) {
			switch (str.charAt(i)) {
			case ' ':
			case '\t':
			case '\n':
			case '\r':
			// case '\b':
			// case '\f':
				break;
			default:
				return false;
			}
		}
		return true;
	}

	/**
	 *  判断不为空
	 * @param str str
	 * @return {boolean}
	 */
	public static boolean notBlank(String str) {
		return !isBlank(str);
	}

	/**
	 *  字符串比较
	 * @param a a
	 * @param b b
	 * @return  boolean
	 */
	public static boolean equals(String a, String b) {
		return a == null ? b == null : a.equals(b);
	}
	
}








© 2015 - 2024 Weber Informatics LLC | Privacy Policy