The java.net.URLEncoder class contains a single static method which encodes strings in x-www-form-url-encoded format
java.net.URLEncoder
URLEncoder.encode(String s)