title: java.net.ConnectException: Connection timed out: connect exception occur
body: <p>I have this code, can you help me to solve this problem?<br>
  I have written this code:</p>
  
  <pre><code>out = new DataOutputStream(urlConnection.getOutputStream());//exception occur
  
  String content = (String) remoteUrlList.get(urlID + ".params");
  content = (content == null ? "" : content + "&amp;") + "content=" +   URLEncoder.encode(textArea.getText());
  if (debug &gt; 0) System.err.println("Capture: " + content);
  out.writeBytes(content);
  out.flush();
  out.close();
  
  // retrieve response from the remote host and display it.
  if (debug &gt; 0) System.err.println("Capture: reading response");
  in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
  String str;
  while (null != ((str = in.readLine()))) {
    System.out.println("Capture: " + str);
  }
  in.close();
  
  doneDialog.pack();
  doneDialog.setVisible(true);
  </code></pre>
  
  <p>The error listing is:</p>
  
  <pre>
     at java.net.PlainSocketImpl.socketConnect(Native Method)
          at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
          at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
          at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
          at java.net.Socket.connect(Socket.java:519)
          at java.net.Socket.connect(Socket.java:469)
          at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
          at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
          at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
          at sun.net.www.http.HttpClient.(HttpClient.java:233)
          at sun.net.www.http.HttpClient.New(HttpClient.java:306)
          at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:795)
          at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:743)
          at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:654)
          at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:832)
          at de.mud.jta.plugin.Capture.saveFile(Capture.java:339)
          at de.mud.jta.plugin.Capture.access$200(Capture.java:83)
          at de.mud.jta.plugin.Capture$4.actionPerformed(Capture.java:173)
          at de.mud.jta.plugin.Capture$10$1.actionPerformed(Capture.java:266)
  </pre>
  
  <p>I am trying this on my local network, so no issue of firewall..<br>
  Can anyone help?</p>
  
  <p>krunal patel</p>