国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Java > 正文

Java掩碼的幾種使用例舉

2024-07-14 08:43:36
字體:
來源:轉載
供稿:網友

java掩碼

 private static String nameMask(String name) throws Exception { if(name ==null)throw new Exception("請輸入要掩碼的字符串"); if(name.length()<=1) return name+"*"; return name.replaceAll("([//u4e00-//u9fa5]{1})(.*)", "$1"+createAsterisk(name.length()-1)); } private static String createAsterisk(int len) { StringBuffer sb = new StringBuffer(); for(int i=0;i<len;i++){  sb.append("*"); } return sb.toString(); }
/** * 對客戶證件號碼做掩碼 *  * */ public static String maskCertId(String certId) throws Exception { if(certId==null||certId.length()==0) return ""; if(certId.length()==18) {  String v = certId.substring(0,4);  String end = certId.substring(certId.length()-4);  return v+StringUtils.repeat("*",8)+end; } else  return ""; }
/** * 對客戶姓名做掩碼 * @throws JBOException  * */ public static String maskUserName(String userName) throws Exception { if(userName==null||userName.length()==0) return ""; String v = userName.substring(0,1); return StringUtils.rightPad(v, userName.length(),"*");//StringUtils.rightPad方法做一個字符串右補齊 }
/** * 對字符串進行脫敏處理 * @param word 被脫敏的字符 * @param startLength 被保留的開始長度 0代表不保留 * @param endLength 被保留的結束長度 0代表不保留 * @param pad 填充字符 * */ public static String wordMask(String word,int startLength ,int endLength,String pad)  { if(word==null) return StringUtils.leftPad("", startLength+endLength,pad); if(word.length()<=startLength+endLength) return StringUtils.leftPad("", startLength+endLength,pad); String startStr = ""; String endStr = ""; int padLength = 0; if(word.length()>startLength) startStr = StringUtils.substring(word, 0,startLength); if(word.length()>startLength+endLength) endStr = StringUtils.substring(word, word.length()-endLength); padLength = word.length()-startLength-endLength; return startStr + StringUtils.repeat(pad, padLength)+endStr; }

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對VeVb武林網的支持。


注:相關教程知識閱讀請移步到JAVA教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 荔波县| 鹤庆县| 洛隆县| 读书| 双辽市| 河北省| 靖江市| 弥渡县| 松江区| 饶平县| 麻城市| 成武县| 安福县| 东城区| 海口市| 清徐县| 扶风县| 溆浦县| 兴安盟| 玉溪市| 如皋市| 五河县| 临桂县| 博客| 兴隆县| 张家界市| 贵州省| 德清县| 宁晋县| 循化| 庐江县| 黑山县| 慈利县| 赤壁市| 襄樊市| 白玉县| 邯郸市| 阳曲县| 乌鲁木齐县| 庄浪县| 盐池县|