How to Mask Field by partially

public static String mask(String clearText, int showFirstDigitCount, int showLastDigitCount) { if(clearText == null || "".equalsIgnoreCase(clearText)) { return clearText; } if ((clearText.length() <= showFirstDigitCount) || (clearText.length() <= showLastDigitCount) || (clearText.length() <= (showFirstDigitCount+showLastDigitCount))) { return clearText; } StringBuilder maskedString = new StringBuilder(); maskedString.append(StringUtils.left(clearText, showFirstDigitCount)); maskedString.append(StringUtils.repeat("*", clearText.length() - (showFirstDigitCount + showLastDigitCount))); maskedString.append(StringUtils.right(clearText, showLastDigitCount)); return maskedString.toString(); } edit ObjectMapper mapper = new ObjectMapper(); Map jsonStringMap = mapper.readValue(jsonString, Map.class); mapper.writeValueAsString(jsonStringMap); Source: https://gist.github.com/ufuk/481c02a0694f654167eb00116be02cac --------------------------------- json string pretty writer https://mkyong.com/java/how-to-enable-pretty-print-json-output-jackson/

Yorumlar

Bu blogdaki popüler yayınlar

Bir Yazılımcının karşılaşabileceği Mülakat Soruları Karşılaştıklarım

[Java] Append Nedir

WebSocket Nedir?