• Post Reply Bookmark Topic Watch Topic
  • New Topic

request time out trouble

sksharma sharma
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear all ,
i have made a simple program that read the contents of an HTML page , but i am facing a small problem . the problem is, when i run the program on my system then it works properly means it shows us the contents of the desired web page, but when i run it on other system that uses different proxy then it throws error

java.net.ConnectException: Connection timed out: connect

can any body help me out
This is the sample of my code

* Created by IntelliJ IDEA.
* User: varungoyal
* Date: Feb 9, 2006
* Time: 5:51:34 PM
* To change this template use File | Settings | File Templates.
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class SendPostRequest {
private static InputStream stream = null;
public static void main(String args[]){
public static void execute(){

try {
System.out.println("CONTROL HERE ");
URL myURL = new URL("http://yahoo.com");
HttpURLConnection urlc = (HttpURLConnection) myURL.openConnection();
System.out.println("GET RESPONSE CODE =====> "+urlc.getResponseCode());
try {
stream = urlc.getInputStream();
int size= stream.available();
while(size!=0) {
byte data[] = new byte[size];
int num_read = stream.read(data);
byte[] actualdata = new byte[num_read];
String webData=new String(actualdata);

if(stream.read()== -1) {
catch(Exception e){
System.out.println("________________ error while reading _____________________");

catch (IOException ex) {
System.out.print("ERROR IN REQUESTING URL ");


PJ Crump
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you were using HttpClient then you would just say
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!