What happened to URIUtil.encodePath from commons-httpclient-3.1?

I want to do what is described in question 724043 , namely to encode the components of a URI path. The recommended class for this is the URIUtil from Commons HttpClient 3.1. Unfortunately, this class seems to have disappeared from the latest version of HttpClient. A similarly named class from HttpClient 4.1, URIUtils , does not provide the same functionality. Has this class / method been moved to some other library that I don’t know about or is just missing? Am I best off just copying a class from version 3.1 into my code, or is there an easier way?

+8
java uri encoding escaping
Apr 09 '10 at 7:33
source share
1 answer

The drafters of the module decided that the standard UDK class should be used instead :

The reason URIs and URIUtils is replaced by the standard Java URI is very simple: no one wanted to support these classes.

There are several useful methods that help problems with the implementation of java.net.URI, but otherwise the standard JRE class should be sufficient, right?

So, the easiest way is to look at the source of encodePath from release 3.1 and duplicate what it does in its own code (or just copy the method / class to your code base).

Or you can go with the accepted answer to the question you were talking about (but it seems you need to split the URL first into parts):

new URI( "http", "search.barnesandnoble.com", "/booksearch/first book.pdf", null).toString(); 
+7
Apr 09 2018-10-09T00:
source



All Articles