123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package com.sooka.common.utils;
- import org.apache.commons.lang3.StringUtils;
- import java.util.Arrays;
- import java.util.HashSet;
- import java.util.Set;
- import java.util.UUID;
- public class StrUtil {
- /**
- * 判断字符串是否为空
- * @param str
- * @return
- */
- public static boolean isBlank(String str) {
- return str == null || str.length() <= 0;
- }
- /**
- * 替换中文逗号
- * @param content
- * @return
- */
- public static String replace(String content) {
- String word = content.replace(",", ",").trim();
- return word;
- }
- /**
- * 获取文件扩展名
- *
- * @param filename
- * @return
- */
- public static String getExtensionName(String filename) {
- if ((filename != null) && (filename.length() > 0)) {
- int dot = filename.lastIndexOf('.');
- if ((dot > -1) && (dot < (filename.length() - 1))) {
- return filename.substring(dot + 1);
- }
- }
- return filename;
- }
- /**
- *
- * 获取uuid
- *
- * @return
- */
- public static String getUUID() {
- UUID uuid = UUID.randomUUID();
- return uuid.toString().replace("-", "");
- }
- /* 字符串数组排重 */
- public static String[] excludeRepeatStr(String str){
- if(StrUtil.isBlank(str)) {
- return null;
- }
- String[] ss = str.replace(" ","").split(",");
- Arrays.sort(ss);
- Set<String> prodCodeSet = new HashSet<>();
- prodCodeSet.addAll(Arrays.asList(ss));
- ss = prodCodeSet.toArray(new String[]{});
- return ss;
- }
- public static boolean isNotNumeric(String ...strs) {
- for(String str:strs){
- if(StringUtils.isNumeric(str)) {
- return false;
- }
- }
- return true;
- }
- public static boolean isContain(String[] strs,String str) {
- if(CmsUtil.isNullOrEmpty(strs)) {
- return false;
- }
- for(String s:strs){
- if(s.equals(str)) {
- return true;
- }
- }
- return false;
- }
- /*判断一个字符是否是中文*/
- public static boolean isChinese(char c) {
- return c >= 0x4E00 && c <= 0x9FA5;
- }
- /*判断一个字符串是否含有中文*/
- public static boolean isChinese(String str) {
- if (str == null) {
- return false;
- }
- for (char c : str.toCharArray()) {
- if (isChinese(c)) {
- return true;
- }
- }
- return false;
- }
- public static void main(String args[]){
- // System.out.println( excludeRepeatStr("1,2,1"));
- // System.out.println(isNotNumeric("0","46"));
- String[] ss = {"1000","200"};
- System.out.println(isContain(ss,"200"));
- }
- }
|