If I receive an emailAddress in the following format:
example%40gmail.com
In Java how do I convert it to this:
[email protected]
Use URLDecoder.decode(String s, String enc) becuase URLDecoder.decode(String s) is deprecated in Java 1.5.
Here is the code to test your case:
@Test
public void testUrlDecoder() throws UnsupportedEncodingException {
String encodedStr = "example%40gmail.com";
String decodedStr = URLDecoder.decode(encodedStr, "UTF-8");
assertEquals("[email protected]", decodedStr);
}
See the answer to this question: Java: How to unescape HTML character entities in Java?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With