title: How to produce ConnectException on purpose?
body: <p>I am using java <code>HttpURLConnection</code> class to connect to a url, and I want to produce ConnectException to monitor and record some data. i am just trying to connect random websites but I couldn't be able to produce <code>ConnectionException</code> even though when I am trying to visit the url which doesn't exist but it is catching <code>MalformedURLException</code></p>
  
  <p>from Java Docs of <code>ConnectException</code>,</p>
  
  <p><a href="http://docs.oracle.com/javase/7/docs/api/java/net/ConnectException.html#ConnectException()" rel="nofollow">http://docs.oracle.com/javase/7/docs/api/java/net/ConnectException.html#ConnectException()</a></p>
  
  <blockquote>
    <p>Signals that an error occurred while attempting to connect a socket to
    a remote address and port. Typically, the connection was refused
    remotely (e.g., no process is listening on the remote address/port).</p>
  </blockquote>
  
  <p>It means that the connection needed to be refused from the remote server, but I don't know what does that mean and how to produce it from my java code ?</p>