From 1a1a315efb1b5dc294013126f35819e36565040c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 30 九月 2021 18:06:48 +0800
Subject: [PATCH] 后台管理自动化代码生成

---
 src/main/java/org/yeshi/utils/StringUtil.java |  565 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 286 insertions(+), 279 deletions(-)

diff --git a/src/main/java/org/yeshi/utils/StringUtil.java b/src/main/java/org/yeshi/utils/StringUtil.java
index 61db38d..bce6048 100644
--- a/src/main/java/org/yeshi/utils/StringUtil.java
+++ b/src/main/java/org/yeshi/utils/StringUtil.java
@@ -17,314 +17,321 @@
 
 public class StringUtil {
 
-	// 鍒ゆ柇鏄惁涓烘墜鏈哄彿鐮�
-	public static boolean isMobile(String mobile) {
+    // 鍒ゆ柇鏄惁涓烘墜鏈哄彿鐮�
+    public static boolean isMobile(String mobile) {
 
-		String regex = "^((13[0-9])|(17[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$";
-		Pattern p = Pattern.compile(regex);
-		Matcher m = p.matcher(mobile);
+        String regex = "^((13[0-9])|(17[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$";
+        Pattern p = Pattern.compile(regex);
+        Matcher m = p.matcher(mobile);
 
-		if (mobile == null || mobile.equals("") || mobile.length() != 11) {
+        if (mobile == null || mobile.equals("") || mobile.length() != 11) {
 
-			return false;
+            return false;
 
-		} else {
-			return m.find();
-		}
-	}
+        } else {
+            return m.find();
+        }
+    }
 
-	/**
-	 * 鑾峰彇鏁板瓧鍜屽瓧姣嶇殑闅忔満鐮�
-	 * 
-	 * @param count
-	 * @return
-	 */
-	public static String getRandomCode(int count) {
-		String sts = "0123456789abcdefghijklmnopqrsduvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
-		String code = "";
-		for (int i = 0; i < count; i++) {
-			int p = (int) (Math.random() * 62);
-			code += sts.charAt(p);
-		}
-		return code;
-	}
+    /**
+     * 鑾峰彇鏁板瓧鍜屽瓧姣嶇殑闅忔満鐮�
+     *
+     * @param count
+     * @return
+     */
+    public static String getRandomCode(int count) {
+        String sts = "0123456789abcdefghijklmnopqrsduvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+        String code = "";
+        for (int i = 0; i < count; i++) {
+            int p = (int) (Math.random() * 62);
+            code += sts.charAt(p);
+        }
+        return code;
+    }
 
-	/**
-	 * 鑾峰彇6浣嶆暟瀛楅獙璇佺爜
-	 * 
-	 * @return
-	 */
-	public static String getVerifyCode() {
-		String sts = "0123456789";
-		String code = "";
-		for (int i = 0; i < 6; i++) {
-			int p = (int) (Math.random() * 10);
-			code += sts.charAt(p);
-		}
-		return code;
-	}
+    /**
+     * 鑾峰彇6浣嶆暟瀛楅獙璇佺爜
+     *
+     * @return
+     */
+    public static String getVerifyCode() {
+        String sts = "0123456789";
+        String code = "";
+        for (int i = 0; i < 6; i++) {
+            int p = (int) (Math.random() * 10);
+            code += sts.charAt(p);
+        }
+        return code;
+    }
 
-	/**
-	 * 鍒ゆ柇瀛楃涓叉槸鍚︿负绌�
-	 * 
-	 * @param text
-	 * @return
-	 */
-	public static boolean isNullOrEmpty(String text) {
-		if (text == null || text.trim().length() == 0 || text.equalsIgnoreCase("null")) {
-			return true;
-		}
-		return false;
-	}
+    /**
+     * 鍒ゆ柇瀛楃涓叉槸鍚︿负绌�
+     *
+     * @param text
+     * @return
+     */
+    public static boolean isNullOrEmpty(String text) {
+        if (text == null || text.trim().length() == 0 || text.equalsIgnoreCase("null")) {
+            return true;
+        }
+        return false;
+    }
 
-	/**
-	 * 32涓篗D5灏忓啓鍔犲瘑
-	 * 
-	 * @param st
-	 * @return
-	 */
-	public static String Md5(String st) {
-		try {
-			MessageDigest md = MessageDigest.getInstance("MD5");
-			try {
-				md.update(st.getBytes("UTF-8"));
-			} catch (UnsupportedEncodingException e) {
-				e.printStackTrace();
-			}
-			byte b[] = md.digest();
+    /**
+     * 32涓篗D5灏忓啓鍔犲瘑
+     *
+     * @param st
+     * @return
+     */
+    public static String Md5(String st) {
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            try {
+                md.update(st.getBytes("UTF-8"));
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            byte b[] = md.digest();
 
-			int i;
+            int i;
 
-			StringBuffer buf = new StringBuffer("");
-			for (int offset = 0; offset < b.length; offset++) {
-				i = b[offset];
-				if (i < 0)
-					i += 256;
-				if (i < 16)
-					buf.append("0");
-				buf.append(Integer.toHexString(i));
-			}
-			return buf.toString();
-			// LogUtil.i("result: " + buf.toString());// 32位锟侥硷拷锟斤拷
-			// LogUtil.i("result: " + buf.toString().substring(8,
-			// 24));// 16位锟侥硷拷锟斤拷
-		} catch (NoSuchAlgorithmException e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
+            StringBuffer buf = new StringBuffer("");
+            for (int offset = 0; offset < b.length; offset++) {
+                i = b[offset];
+                if (i < 0)
+                    i += 256;
+                if (i < 16)
+                    buf.append("0");
+                buf.append(Integer.toHexString(i));
+            }
+            return buf.toString();
+            // LogUtil.i("result: " + buf.toString());// 32位锟侥硷拷锟斤拷
+            // LogUtil.i("result: " + buf.toString().substring(8,
+            // 24));// 16位锟侥硷拷锟斤拷
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 
-	public static String MD5Hmac(String st, String key) {
-		try {
-			return HmacUtils.byte2hex(HmacUtils.encryptHMAC(st, key));
-		} catch (InvalidKeyException e) {
-			e.printStackTrace();
-		} catch (NoSuchAlgorithmException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
+    public static String MD5Hmac(String st, String key) {
+        try {
+            return HmacUtils.byte2hex(HmacUtils.encryptHMAC(st, key));
+        } catch (InvalidKeyException e) {
+            e.printStackTrace();
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 
-	/**
-	 * 灏唍ull杞负绌哄瓧绗︿覆
-	 * 
-	 * @param st
-	 * @return
-	 */
-	public static String getString(String st) {
-		return isNullOrEmpty(st) ? "" : st;
-	}
+    /**
+     * 灏唍ull杞负绌哄瓧绗︿覆
+     *
+     * @param st
+     * @return
+     */
+    public static String getString(String st) {
+        return isNullOrEmpty(st) ? "" : st;
+    }
 
-	/**
-	 * 灏嗘暣鏁拌浆涓哄瓧绗︿覆
-	 * 
-	 * @param i
-	 * @return
-	 */
-	public static String getString(int i) {
-		return getString(i + "");
-	}
+    /**
+     * 灏嗘暣鏁拌浆涓哄瓧绗︿覆
+     *
+     * @param i
+     * @return
+     */
+    public static String getString(int i) {
+        return getString(i + "");
+    }
 
-	/**
-	 * 灏嗛暱鏁村舰杞负瀛楃涓�
-	 * 
-	 * @param i
-	 * @return
-	 */
-	public static String getString(long i) {
-		return getString(i + "");
-	}
+    /**
+     * 灏嗛暱鏁村舰杞负瀛楃涓�
+     *
+     * @param i
+     * @return
+     */
+    public static String getString(long i) {
+        return getString(i + "");
+    }
 
-	/**
-	 * 鑾峰彇鐢佃瘽鍙风爜鐨勯殣钘忔牸寮�
-	 * 
-	 * @param mobile
-	 * @return
-	 */
-	public static String getSubMobile(String mobile) {
-		if (!StringUtil.isNullOrEmpty(mobile) && mobile.length() > 10) {
-			return mobile.subSequence(0, 3).toString() + "****" + mobile.subSequence(7, mobile.length()).toString();
-		} else
-			return mobile;
-	}
+    /**
+     * 鑾峰彇鐢佃瘽鍙风爜鐨勯殣钘忔牸寮�
+     *
+     * @param mobile
+     * @return
+     */
+    public static String getSubMobile(String mobile) {
+        if (!StringUtil.isNullOrEmpty(mobile) && mobile.length() > 10) {
+            return mobile.subSequence(0, 3).toString() + "****" + mobile.subSequence(7, mobile.length()).toString();
+        } else
+            return mobile;
+    }
 
-	/**
-	 * BASE64鍔犲瘑
-	 * 
-	 * @param b
-	 * @return
-	 */
-	@SuppressWarnings("restriction")
-	public static String getBase64FromByte(byte[] b) {
+    /**
+     * BASE64鍔犲瘑
+     *
+     * @param b
+     * @return
+     */
+    @SuppressWarnings("restriction")
+    public static String getBase64FromByte(byte[] b) {
 
-		String s = null;
-		if (b != null) {
-			s = new BASE64Encoder().encode(b);
-		}
-		return s;
-	}
+        String s = null;
+        if (b != null) {
+            s = new BASE64Encoder().encode(b);
+        }
+        return s;
+    }
 
-	/**
-	 * 鎻愬彇瀛楃涓蹭腑鐨勬墍鏈夋暟瀛�
-	 * 
-	 * @param st
-	 * @return
-	 */
-	public static String getNumberFromString(String st) {
-		String number = "";
-		Pattern p = Pattern.compile("[0-9\\.]+");
-		Matcher m = p.matcher(st);
+    /**
+     * 鎻愬彇瀛楃涓蹭腑鐨勬墍鏈夋暟瀛�
+     *
+     * @param st
+     * @return
+     */
+    public static String getNumberFromString(String st) {
+        String number = "";
+        Pattern p = Pattern.compile("[0-9\\.]+");
+        Matcher m = p.matcher(st);
 
-		while (m.find()) {
-			number += (m.group() + ",");
-		}
-		return number;
-	}
+        while (m.find()) {
+            number += (m.group() + ",");
+        }
+        return number;
+    }
 
-	/**
-	 * 灏嗗瓧绗︿覆杞负UTF-8缂栫爜
-	 * 
-	 * @param resource
-	 * @param chactor
-	 * @return
-	 */
-	public static String getUTF8String(String resource, String chactor) {
-		if (!isNullOrEmpty(resource)) {
-			try {
-				return new String(resource.getBytes(chactor), "UTF-8");
-			} catch (UnsupportedEncodingException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-		}
-		return "";
-	}
+    /**
+     * 灏嗗瓧绗︿覆杞负UTF-8缂栫爜
+     *
+     * @param resource
+     * @param chactor
+     * @return
+     */
+    public static String getUTF8String(String resource, String chactor) {
+        if (!isNullOrEmpty(resource)) {
+            try {
+                return new String(resource.getBytes(chactor), "UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+        }
+        return "";
+    }
 
-	/**
-	 * Base64鍔犲瘑
-	 * 
-	 * @param str
-	 * @return
-	 * @throws Exception
-	 */
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public static String getBase64String(String str) throws Exception {
-		byte[] input = str.getBytes("UTF-8");
-		Class clazz = Class.forName("com.sun.org.apache.xerces.internal.impl.dv.util.Base64");
-		Method mainMethod = clazz.getMethod("encode", byte[].class);
-		mainMethod.setAccessible(true);
-		Object retObj = mainMethod.invoke(null, new Object[] { input });
-		return (String) retObj;
-	}
-	
+    /**
+     * Base64鍔犲瘑
+     *
+     * @param str
+     * @return
+     * @throws Exception
+     */
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    public static String getBase64String(String str) throws Exception {
+        byte[] input = str.getBytes("UTF-8");
+        Class clazz = Class.forName("com.sun.org.apache.xerces.internal.impl.dv.util.Base64");
+        Method mainMethod = clazz.getMethod("encode", byte[].class);
+        mainMethod.setAccessible(true);
+        Object retObj = mainMethod.invoke(null, new Object[]{input});
+        return (String) retObj;
+    }
 
-	/**
-	 * BASE64瑙e瘑
-	 * 
-	 * @param s
-	 * @return
-	 */
-	public static String getFromBase64(String s) {
-		byte[] b = null;
-		String result = null;
-		if (s != null) {
-			final Base64 base64 = new Base64();
-			try {
-				b = base64.decode(s.getBytes("UTF-8"));
-				result = new String(b, "utf-8");
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-		}
-		return result;
-	}
 
-	/**
-	 * SHA1鍔犲瘑
-	 * 
-	 * @param decript
-	 * @return
-	 */
-	public static String SHA1(String decript) {
-		try {
-			MessageDigest digest = MessageDigest.getInstance("SHA-1");
-			digest.update(decript.getBytes());
-			byte messageDigest[] = digest.digest();
-			// Create Hex String
-			StringBuffer hexString = new StringBuffer();
-			// 瀛楄妭鏁扮粍杞崲锟�?鍗佸叚杩涘埗 锟�?
-			for (int i = 0; i < messageDigest.length; i++) {
-				String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
-				if (shaHex.length() < 2) {
-					hexString.append(0);
-				}
-				hexString.append(shaHex);
-			}
-			return hexString.toString();
+    /**
+     * BASE64瑙e瘑
+     *
+     * @param s
+     * @return
+     */
+    public static String getFromBase64(String s) {
+        byte[] b = null;
+        String result = null;
+        if (s != null) {
+            final Base64 base64 = new Base64();
+            try {
+                b = base64.decode(s.getBytes("UTF-8"));
+                result = new String(b, "utf-8");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return result;
+    }
 
-		} catch (NoSuchAlgorithmException e) {
-			e.printStackTrace();
-		}
-		return "";
-	}
+    /**
+     * SHA1鍔犲瘑
+     *
+     * @param decript
+     * @return
+     */
+    public static String SHA1(String decript) {
+        try {
+            MessageDigest digest = MessageDigest.getInstance("SHA-1");
+            digest.update(decript.getBytes());
+            byte messageDigest[] = digest.digest();
+            // Create Hex String
+            StringBuffer hexString = new StringBuffer();
+            // 瀛楄妭鏁扮粍杞崲锟�?鍗佸叚杩涘埗 锟�?
+            for (int i = 0; i < messageDigest.length; i++) {
+                String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
+                if (shaHex.length() < 2) {
+                    hexString.append(0);
+                }
+                hexString.append(shaHex);
+            }
+            return hexString.toString();
 
-	public static long[] parseLong(String[] arr) {
-		long[] lArr = new long[arr.length];
-		int ii = 0;
-		for (String str : arr) {
-			lArr[ii] = Long.parseLong(str);
-			ii++;
-		}
-		return lArr;
-	}
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
 
-	public static String concat(List list, String sperator) {
-		if (list == null)
-			return null;
-		String str = "";
-		for (Object obj : list) {
-			str += obj + sperator;
-		}
-		if (str.endsWith(sperator))
-			str = str.substring(0, str.length() - sperator.length());
-		return str;
-	}
+    public static long[] parseLong(String[] arr) {
+        long[] lArr = new long[arr.length];
+        int ii = 0;
+        for (String str : arr) {
+            lArr[ii] = Long.parseLong(str);
+            ii++;
+        }
+        return lArr;
+    }
 
-	public static String concat(Object[] array, String sperator) {
-		if (array == null)
-			return null;
+    public static String concat(List list, String sperator) {
+        if (list == null)
+            return null;
+        String str = "";
+        for (Object obj : list) {
+            str += obj + sperator;
+        }
+        if (str.endsWith(sperator))
+            str = str.substring(0, str.length() - sperator.length());
+        return str;
+    }
 
-		String str = "";
-		for (int i = 0; i < array.length; i++) {
-			str += array[i] + sperator;
-		}
+    public static String concat(Object[] array, String sperator) {
+        if (array == null)
+            return null;
 
-		if (str.endsWith(sperator))
-			str = str.substring(0, str.length() - sperator.length());
-		return str;
-	}
+        String str = "";
+        for (int i = 0; i < array.length; i++) {
+            str += array[i] + sperator;
+        }
+
+        if (str.endsWith(sperator))
+            str = str.substring(0, str.length() - sperator.length());
+        return str;
+    }
+
+    //棣栧瓧姣嶅皬鍐�
+    public static String firstCharToLower(String st) {
+        if (st == null || st.length() < 2)
+            return st;
+        return st.substring(0, 1).toLowerCase() + st.substring(1);
+    }
 
 
 }

--
Gitblit v1.8.0