/**
* 显示第一个,隐藏后面
*/
public static String chineseName(String fullName) {
if (fullName == null || fullName.isEmpty()) {
return "";
}
String myName = null;
char[] chars = fullName.toCharArray();
if (chars.length == 1) {
myName = fullName;
}
if (chars.length == 2) {
if (fullName.substring(1).contains("*")) {
myName = fullName;
} else {
myName = fullName.replaceFirst(fullName.substring(1), "*");
}
}
if (chars.length > 2) {
String substring = fullName.substring(1, chars.length - 1);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < substring.length(); i++) {
sb.append("*");
}
myName = fullName.replace(substring, sb.toString());
}
return myName;
}
/**
* 显示前三位和后四位
*/
public static String mobilePhone(String num) {
if (StringUtils.isBlank(num)) {
return "";
}
return StringUtils.left(num, 3).concat(StringUtils.removeStart(StringUtils.leftPad(StringUtils.right(num, 4), StringUtils.length(num), "*"), "***"));
}
/**
* 显示到区的地址
*/
public static String address(String address, int sensitiveSize) {
if (StringUtils.isBlank(address)) {
return "";
}
int length = StringUtils.length(address);
return StringUtils.rightPad(StringUtils.left(address, length - sensitiveSize), length, "*");
}
10-28
08-14
02-10
1390
03-09
1922
02-24
265
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交