1

I have a String that contains for example:

Hello are you ok ? 

I want to convert this String to:

Hello%20are%20you%20ok%20?

What do we call that and how can I do it in Java? Cause when I send a HttpRequest, the server doesn't understand the words without these special characters...

2

1 Answer 1

2

What you want to use is URLEncoder :

String encodedUrl = URLEncoder.encode(url, "UTF-8");

Sign up to request clarification or add additional context in comments.

1 Comment

If url is http://www.google.com/, the encoded form is http%3A%2F%2Fwww.google.com%2F (a mess). The duplicate Q&A answers this much better.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.