tags:

views:

1780

answers:

4

Is there a good url builder for java?

+11  A: 

Apache HTTPClient?

takete.dk
A: 

The URL class has pretty good methods for constructing a URL.

Mike Pone
addParameter() ?
willCode4Beer
-1 : never advice anybody to use the URL class (use URI instead). Reason : http://javaantipatterns.wordpress.com/2007/11/24/comparing-urls-with-urlequals/
chburd
+8  A: 

Using HTTPClient worked well.

protected static String createUrl(List<NameValuePair> pairs) throws URIException{

  HttpMethod method = new GetMethod("http://example.org");
  method.setQueryString(pairs.toArray(new NameValuePair[]{}));

  return method.getURI().getEscapedURI();

}
jon077
Then you should upvote and mark as accepted the answer by takete.dk: http://bit.ly/P3AbL
OscarRyz
A: 

Bug (RFE) 6306820 in the java bug database adresses this.

In one of the comments, a link to the RFE implementation is provided.

Chantal