1import java.io.IOException;
2import java.net.MalformedURLException;
3import java.net.URL;
4import java.net.URLConnection;
5
6public class Tester {
7 public static void main(String[] args) {
8 try {
9 URL url = new URL("http://www.google.com");
10 URLConnection connection = url.openConnection();
11 connection.connect();
12 System.out.println("Internet is connected");
13 } catch (MalformedURLException e) {
14 System.out.println("Internet is not connected");
15 } catch (IOException e) {
16 System.out.println("Internet is not connected");
17 }
18 }
19}