Java Network Interface Check hasNetworkAccess()

Here you can find the source of hasNetworkAccess()

Description

has Network Access

License

LGPL

Declaration

public static boolean hasNetworkAccess() 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.net.*;

public class Main {
    public static boolean hasNetworkAccess() {
        try {/*from  www  .  j  av  a2 s  .  com*/
            final InetAddress address = InetAddress.getByName("www.google.com");
            return true;
        } catch (Throwable ignored) {
        }
        return false;
    }
}

Related

  1. addAllInterfaces(List target, List level)
  2. checkMethod(NetworkInterface iface, Method toCheck)
  3. cloneInterfaces( List interfaces)
  4. describeInterface(NetworkInterface subIf, boolean subinterface)
  5. dumpLocalNetworkInfo()
  6. isCIDR(String network)
  7. isHostInNetworkCard(String host)
  8. isInterfaceLoopback(NetworkInterface iface)
  9. isInterfaceUp(NetworkInterface iface)