masking a creditcard number in java

前端 未结 3 2023
猫巷女王i
猫巷女王i 2021-02-08 16:58

I tried to mask the characters in a creditcard number string using character \'X\'.I wrote two functions as below .The second function uses commons.lang.StringUtils

3条回答
  •  面向向阳花
    2021-02-08 17:20

    Using Apache StringUtils...

    String ccNumber = "123232323767"; 
    
    StringUtils.overlay(ccNumber, StringUtils.repeat("X", ccNumber.length()-4), 0, ccNumber.length()-4);
    

提交回复
热议问题