I use the code from Sun's java tutorial
import java.net.*; import java.io.*; public class URLConnectionReader { public static void main(String[] args) throws Exception { URL yahoo = new URL("http://www.yahoo.com/"); URLConnection yc = yahoo.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); } } Stack trace is same as Connection timed out. Why?
I suspect that might be problem with firewall but
- ping to google.com is okay
- it works in browser
- this approach fails for every URL I provide
- I use DJ WebBrowser component in other program and it works okay as a browser
How can I investigate more about this problem? Can I get to know which port numbers are going to be used when I run the code?
Thanks