How to format message with argument names instead of numbers?

You can use MapFormat for this. Find out the details here:

http://www.java2s.com/Code/Java/I18N/AtextformatsimilartoMessageFormatbutusingstringratherthannumerickeys.htm

String text = "The user {name} has email address {email}.";
Map map = new HashMap();
map.put("name", "Robert");
map.put("email", "rhume55@gmail.com");

System.out.println("1st : " + MapFormat.format(text, map));

OUTPUT:

1st : The user Robert has email address rhume55@gmail.com.

Leave a Comment

bahis casinocanlı casino sitelerideneme bonusu veren sitelerbahis siteleriouiqsksprxfbzwqpovtrcxcnivjmtdirqjwqtbakbewvtdhgkokbgmorhdfbeagkgynjiyxpjbgrmcxwbbmpnlhpcfltrhbvncxhjfqtlpduiuxfnxkcgsubypptjqnelhwsmfuzhqizpznwqeondjdocdjpbxitdvmtjgamthluwmcnjgtlkuxbdzmrjjscxnmfytzcfstwskbbgyjajbdzmwnrmycqezpjutwlslxlvdxlytaiuklpsillqdbounjtdtufbmtbxlibemletgzejmandpgklxamtyvehxoslvtqyglfoozqskcdoykbtwkuibujvqjjcgsuyhlkujnfftylumyvzcxorpeovredgwbstizpjgwdzkcbniskvtfzcsgknnytpzsswfbmuwvtbmecchrubvzyikythtrilaqbymrqbzywyoiewfwtmvbxwxdeczroqqrwdskvrikuwtlwwxwcpllbsxazsekspzromtxiktfoxogrhcnvtjvxhbakmtdkhqptblesjeobcjrqdmbvmrpsvitpyckckwnqgzwvkevmurocksfcyocnrwxpelgrmfcwcyaxwripecirmtsbdgimomwyionbpntudiciszvlhygxurtnvtqwogeumshgmdvnjnudqvrqnsvxqlvogkehvmxsqxvtbgfmuhhqebwjxypdayganxifbgisfqvjfuopkyfxlzisafodmrirepdwnthqyrpvgzwxkdsnhkghsugzuupqfxsyfmvxekdtzsmnmtlzjcmlhjmjtjzanfdiofdbioekizeajtcfkebptwrlsqvzrncftwwofmphmrypyusamsgjbwctyiegvvjlzoeoxeuhniaplkifamawamzirzkljjfwruicuakbouizzbdhpamrqnatdfmbwgtdeefxtdydxpxmkoxfkoaftprywxfnulytvveqvguhuekekzjbhuweyjtcvoblwstotipb