How to check if internet connection is present in java?

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2009-09-09T20:49:01Z Indexed on 2010/04/19 18:13 UTC
Read the original article Hit count: 116

Filed under:
|
|

How do you check if you can connect to the internet via java? One way would be:

final URL url = new URL("http://www.google.com");
final URLConnection conn = url.openConnection();
... if we got here, we should have net ...

But is there something more appropriate to perform that task, especially if you need to do consecutive checks very often and a loss of internet connection is highly probable?

© Stack Overflow or respective owner

Related posts about java

Related posts about connection