/**
* 局部数据模糊化
* @param obj 需要脱敏的数据
* @param startIndex 脱敏起始位置
* @param endIndex 脱敏结束位置
* @return
*/
public static String dataReplace(String obj,int startIndex,int endIndex){
if(null == obj || "".equals(obj)){
obj = "*";
return obj;
}
if(endIndex <= startIndex || obj.length()<endIndex){
obj = "*";
return obj;
}
StringBuffer sb = new StringBuffer(obj.substring(0,startIndex));
String str = obj.substring(startIndex, endIndex);
for(int i=0; i<str.length();i++){
sb.append("*");
}
sb.append(obj.substring(endIndex,obj.length()));
obj=sb.toString();
return obj;
}
public static void main(String[] args){
DepoistOpenaccReturnRes data =new DepoistOpenaccReturnRes();
data.setRealName("迪丽热巴");
data.setuCard("320324199411110095");
data.setDepositNo("60000000000000009");
data.setAuthrzState(dataReplace(data.getAuthrzState(),0,0));
data.setMobilePhone(dataReplace(data.getMobilePhone(),3, 0));
data.setDepositNo(dataReplace(data.getDepositNo(),3,
data.getDepositNo().length()-4));
data.setuCard(dataReplace(data.getuCard(),3,data.getuCard().length()-4));
data.setRealName(dataReplace(data.getRealName(),0,data.getRealName().length()-1));
System.out.println(data.toString());
}