AddressFormatUtil { public static String formatAddress(String address) { String text = ""; if (address != null) { String regex = "(\\w{10})(\\w*)(\\w{10})"; try { text = address.replaceAll(regex, "$1....$3"); } catch (Exception e) { LogUtils.e(e.getMessage(),e.fillInStackTrace()); } } return text; } private  AddressFormatUtil(); static String formatAddress(String address); static String formatTransactionAddress(String address); static String formatClaimRewardRecordAddress(String address);  }
@Test public void formatAddress() { String address = "0x2e95e3ce0a54951eb9a99152a6d5827872dfb4fd"; String text = null; if (address != null) { String regex = "(\\w{10})(\\w*)(\\w{10})"; try { text = address.replaceAll(regex, "$1...$3"); } catch (Exception e) { e.printStackTrace(); } } assertEquals("0x2e95e3ce...7872dfb4fd", text); }