title: How to build URL in Groovy
body: <p>I think, I want to use <a href="http://groovy.codehaus.org/modules/http-builder/apidocs/groovyx/net/http/URIBuilder.html" rel="nofollow"><code>URIBuilder</code></a> here but not entirely sure...</p>
  
  <p>I have the following code:</p>
  
  <pre><code>String serverURL = getServerURL(); // ex: "http://somesrv.example.com"
  String appURL = getAppURL(); // ex: "http://myapp.example.com"
  </code></pre>
  
  <p>I now need to add the two together, so that it produces the following:</p>
  
  <pre><code>http://somesrv.example.com/fizz?widget=http://myapp.example.com
  </code></pre>
  
  <p>But I don't just want to use string bashing (<code>def url = serverURL + "/fizz?widget=" + appURL</code>). Plus I'd like URL encoding, etc. Again, I think <code>URLBuilder</code> is the way to go here, but not sure.</p>
  
  <p>I've seen an example uses JAX-RS' <code>UriBuilder</code>:</p>
  
  <pre><code>String url = UriBuilder.fromUri(serverURL).path("fizz").queryParam("widget", appURL).build();
  </code></pre>
  
  <p>Now I just need to figure out how to do this in Groovy?</p>