
win.hupubao.common.utils.StringUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hupubao-common Show documentation
Show all versions of hupubao-common Show documentation
简单封装公共工具,二维码工具,驼峰转换工具,des加解密工具,http访问工具,字符串工具,日期工具
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package win.hupubao.common.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
/**
* @author feihong
* @date 2017-08-10
*/
public class StringUtils {
public static boolean isBlank(Object obj) {
return obj == null || org.apache.commons.lang3.StringUtils.isBlank(obj.toString())
|| obj.toString().equalsIgnoreCase("null");
}
public static boolean isNotBlank(Object obj) {
return !isBlank(obj);
}
public static boolean isEmpty(Object obj) {
return obj == null || obj.toString().isEmpty();
}
public static boolean isNotEmpty(Object obj) {
return !isEmpty(obj);
}
public static Integer parseInteger(String str) {
String regEx = "[^0-9]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
return Integer.valueOf(m.replaceAll("").trim());
}
/**
* 首字母转大写
*
* @param name
* @return
*/
public static String firstToUpperCase(String name) {
return StringUtils.isBlank(name) ? "" : name.substring(0, 1).toUpperCase() + name.substring(1);
}
/**
* 首字母转小写
*
* @param name
* @return
*/
public static String firstToLowerCase(String name) {
return StringUtils.isBlank(name) ? "" : name.substring(0, 1).toLowerCase() + name.substring(1);
}
public static String join(Object[] strAry, String join) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < strAry.length; i++) {
if (i == (strAry.length - 1)) {
sb.append(strAry[i]);
} else {
sb.append(strAry[i]).append(join);
}
}
return new String(sb);
}
/**
* @param htmlStr
* @return 删除Html标签
*/
public static String delHTMLTag(String htmlStr) {
String regExScript = "