title: Build URL in java
body: <p>Trying to build <code>http://IP:4567/foldername/1234?abc=xyz</code>. I don't know much about it but I wrote below code from searching from google:</p>
  
  <pre><code>import java.net.MalformedURLException;
  import java.net.URI;
  import java.net.URL;
  
  public class MyUrlConstruct {
  
      public static void main(String a[]){
  
          try {
              String protocol = "http";
              String host = "IP";
              int port = 4567;
              String path = "foldername/1234";
              URL url = new URL (protocol, host, port, path);
              System.out.println(url.toString()+"?");
          } catch (MalformedURLException ex) {
              ex.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>I am able to build URL <code>http://IP:port/foldername/1234?</code>. I am stuck at query part. Please help me to move forward. </p>