title: How to send username / password to a webserver and authenticate?
body: <p>I am trying to login to a webserver using the following code. </p>
  
  <pre><code>   StringBuilder response = new StringBuilder();
     URL url = new URL("http://www.mocky.io/v2/568e3d730f0000da3fd1831b");
     HttpURLConnection con = (HttpURLConnection) url.openConnection();
  </code></pre>
  
  <p>I have a username and password to login to the server, how do i login using the username/password i have, do i add them to the url before opening a connection or how does it work? </p>
  
  <p>Thanks.</p>