To encode a URL in Java you can use the following snippet.
Also take a look at How to decode a URL in Java.

Sample Java

URLEncoder.encode("https://codesnippets.fesslersoft.de/");  

One thought on “How to encode a URL in Java”

Leave a Reply