My Java standalone application gets a URL (which points to a file) from the user and I need to hit it and download it. The problem I am facing is that I am not able to encod
This is more of a note than an answer. For the above, commons http client URIUtil is still the most convenient and straightforward method to encode different parts of an URI. Unfortunately it is deprecated, the reason cannot be immediately ascertained. Though URIUtil may not cover all the corner cases, it is still the most uncomplicated approach.
I have searched for many library/methods to do this, however, none of them (my view here) provided a simple approach.
I finally took the URIUtil and its dependency code and recompiled, which is working very well for me.
While I don't expect anyone to follow this approach, however, if someone requires, below are the dependencies for compilation (from commons http client 3):