title: Java class to downlaod file
body: <p>I am trying to download a file using simple java class using the following code:  </p>
  
  <p><a href="https://stackoverflow.com/questions/10104655/simple-java-class-to-download-the-file">Simple java class to download the file</a>  </p>
  
  <p>Its giving me following error for my url:   </p>
  
  <pre><code>java.net.ConnectException: Connection refused: connect  
  at java.net.PlainSocketImpl.socketConnect(Native Method)  
  at java.net.PlainSocketImpl.doConnect(Unknown Source)  
  at java.net.PlainSocketImpl.connectToAddress(Unknown Source)  
  at java.net.PlainSocketImpl.connect(Unknown Source)  
  at java.net.Socket.connect(Unknown Source)  
  at java.net.Socket.connect(Unknown Source)  
  at sun.net.NetworkClient.doConnect(Unknown Source)  
  at sun.net.www.http.HttpClient.openServer(Unknown Source)  
  at sun.net.www.http.HttpClient.openServer(Unknown Source)  
  at sun.net.www.http.HttpClient.&lt;init&gt;(Unknown Source)  
  at sun.net.www.http.HttpClient.New(Unknown Source)  
  at sun.net.www.http.HttpClient.New(Unknown Source)  
  at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)  
  at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)  
  at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)  
  at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)  
  at Download.URLSetUp(Download.java:32)  
  at Download.main(Download.java:16)  
  </code></pre>
  
  <p>Please let me know if any of you have got any soultion. </p>
  
  <p>Thanks<br>
  Sneha</p>