mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-12 03:09:48 +08:00
新增工具类
This commit is contained in:
@@ -5,6 +5,8 @@ import com.jsowell.common.core.text.StrFormatter;
|
|||||||
import org.springframework.util.AntPathMatcher;
|
import org.springframework.util.AntPathMatcher;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串工具类
|
* 字符串工具类
|
||||||
@@ -515,20 +517,15 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
*/
|
*/
|
||||||
public static String byteArray2HexString(byte[] arrBytes, int count, boolean blank) {
|
public static String byteArray2HexString(byte[] arrBytes, int count, boolean blank) {
|
||||||
String ret = "";
|
String ret = "";
|
||||||
if (arrBytes == null || arrBytes.length < 1)
|
if (arrBytes == null || arrBytes.length < 1) return ret;
|
||||||
return ret;
|
if (count > arrBytes.length) count = arrBytes.length;
|
||||||
if (count > arrBytes.length)
|
|
||||||
count = arrBytes.length;
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
ret = Integer.toHexString(arrBytes[i] & 0xFF).toUpperCase();
|
ret = Integer.toHexString(arrBytes[i] & 0xFF).toUpperCase();
|
||||||
if (ret.length() == 1)
|
if (ret.length() == 1) builder.append("0").append(ret);
|
||||||
builder.append("0").append(ret);
|
else builder.append(ret);
|
||||||
else
|
if (blank) builder.append(" ");
|
||||||
builder.append(ret);
|
|
||||||
if (blank)
|
|
||||||
builder.append(" ");
|
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
@@ -558,4 +555,36 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是不是电子邮箱
|
||||||
|
*
|
||||||
|
* @param email
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isEmail(String email) {
|
||||||
|
if (email == null || email.length() < 1 || email.length() > 256) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Pattern pattern = Pattern.compile("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
|
||||||
|
return pattern.matcher(email).matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证是否是正确合法的手机号码
|
||||||
|
*
|
||||||
|
* @param phoneNumber
|
||||||
|
* @return 合法返回true,不合法返回false
|
||||||
|
*/
|
||||||
|
public static boolean isPhoneNumber(String phoneNumber) {
|
||||||
|
if (phoneNumber == null || phoneNumber.length() < 1 || phoneNumber.length() > 11) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Pattern pattern = Pattern.compile("^1[3,4,5,6,7,8,9]\\d{9}$");
|
||||||
|
Matcher matcher = pattern.matcher(phoneNumber);
|
||||||
|
if (matcher.matches()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user