Check internet access

Please let me know what is the simplest way to check if the machine has internet access through Java code.

Thanks!
dshrenikAsked:
Who is Participating?
 
for_yanCommented:
Just try to open HTTPcopnnection to www.google.com
0
 
for_yanCommented:


You can use this example to open connection (but can use even some more reliable site, like Google):
http://www.java2s.com/Code/JavaAPI/javax.net/URLopenConnection.htm
0
 
dshrenikAuthor Commented:
Can you tell me how I can turn of DNS caching in the Java runtime.
The solution here says that I must do that to be on the safer side:
http://stackoverflow.com/questions/1139547/detect-internet-connection-using-java

Thanks!
0
 
dshrenikAuthor Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.