How to detect internet connectivity using java program

Posted by Sunil Kumar Sahoo on Stack Overflow See other posts from Stack Overflow or by Sunil Kumar Sahoo
Published on 2010-03-11T03:59:55Z Indexed on 2010/03/11 5:08 UTC
Read the original article Hit count: 320

Filed under:
|

How to write a java program which will tell me whether I have internet access or not. I donot want to ping or create connection with some external url because if that server will be down then my program will not work. I want reliable way to detect which will tell me 100% guarantee that whether I have internet connection or not irrespective of my Operating System. I want the program for the computers who are directly connected to internet.

I have tried with the below program

URL url = new URL("http://www.xyz.com/");

            URLConnection conn = url.openConnection();
            conn.connect();

I want something more appropriate than this program

Thanks Sunil Kumar Sahoo

© Stack Overflow or respective owner

Related posts about network-programming

Related posts about java