It is very often required to test the internet connection for performing some operations. If there is no internet connection established, then alternative logic will be executed. Java provides useful classes in java.net package for connecting to the internet. Here I written a very simple example to test if your system is connected to internet. …