Encoding an URL should be a very simple task. First time I encountered this I did not expect having to do an online research to find an article showing how to do it without using deprecated classes like URLEncoder.
Anyhow. Below a solution that works for me.
Source Code
1
2
3
4
5
6
7
8
9
10
11