i wrote a code for download image from the website using URL class in java.The code is working fine.But the problem is after some time it shows- java.net.ConnectException:Connection timed out
.Here i didnt use any proxy server and firewall.some sites gave soln as like change proxy settings or it is firewall problems.Can u give some solution to solve this problem.

manfosys,

Here is a sample.

import java.io.*;
import java.net.*;

public class Test{
  public static void main(String[] args) throws Exception {
  URL url = new URL("http://www.daniweb.com/forums/member424507.html");   
  String passwdstring = "username:password";
  String encoding = new 

sun.misc.BASE64Encoder().encode(passwdstring.getBytes());

   URLConnection uc = url.openConnection();
   uc.setRequestProperty("Authorization", "Basic " + encoding);
   InputStream content = (InputStream)uc.getInputStream();
   BufferedReader in   = new BufferedReader (new InputStreamReader(content)); 

   String line;   
      while ((line = in.readLine()) != null) 
        {
          System.out.println (line);   
         }
    in.close();
  }
}

manfosys,

Don't create too many threads for the single question.

Welcome bidziilturner,

Great Post

Thank you. It's not true. It's a copy of program.
Did you read this?
1.
How to post threads?
2.
Homework rule.

[/text]
i need ur help to solve the
java.net.ConnectException:Connection timed out

[/text]