package com.gkhy.safePlatform.commons.utils; import sun.misc.BASE64Encoder; import java.math.BigInteger; import java.nio.charset.Charset; import java.security.MessageDigest; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * 继承自Spring util的工具类,减少jar依赖 * @author L.cm */ public class StringUtils extends org.springframework.util.StringUtils { /** * Check whether the given {@code CharSequence} contains actual text. *
More specifically, this method returns {@code true} if the * {@code CharSequence} is not {@code null}, its length is greater than * 0, and it contains at least one non-whitespace character. *
* StringUtils.isBlank(null) = true * StringUtils.isBlank("") = true * StringUtils.isBlank(" ") = true * StringUtils.isBlank("12345") = false * StringUtils.isBlank(" 12345 ") = false ** @param str the {@code CharSequence} to check (may be {@code null}) * @return {@code true} if the {@code CharSequence} is not {@code null}, * its length is greater than 0, and it does not contain whitespace only * @see Character#isWhitespace */ public static boolean isBlank(final CharSequence cs) { return !StringUtils.isNotBlank(cs); } /** *
Checks if a CharSequence is not empty (""), not null and not whitespace only.
* ** StringUtils.isNotBlank(null) = false * StringUtils.isNotBlank("") = false * StringUtils.isNotBlank(" ") = false * StringUtils.isNotBlank("bob") = true * StringUtils.isNotBlank(" bob ") = true ** * @param cs the CharSequence to check, may be null * @return {@code true} if the CharSequence is * not empty and not null and not whitespace * @see Character#isWhitespace */ public static boolean isNotBlank(final CharSequence cs) { return StringUtils.hasText(cs); } /** * Convert a {@code Collection} into a delimited {@code String} (e.g. CSV). *
Useful for {@code toString()} implementations. * @param coll the {@code Collection} to convert * @param delim the delimiter to use (typically a ",") * @return the delimited {@code String} */ public static String join(Collection> coll, String delim) { return StringUtils.collectionToDelimitedString(coll, delim); } /** * Convert a {@code String} array into a delimited {@code String} (e.g. CSV). *
Useful for {@code toString()} implementations.
* @param arr the array to display
* @param delim the delimiter to use (typically a ",")
* @return the delimited {@code String}
*/
public static String join(Object[] arr, String delim) {
return StringUtils.arrayToDelimitedString(arr, delim);
}
public static List