Java Utililty Methods Network Interface Get

List of utility methods to do Network Interface Get

Description

The list of methods to do Network Interface Get are organized into topic(s).

Method

booleanisNixMashPC()
is Nix Mash PC
boolean isNixMashPC = false;
try {
    for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) {
        NetworkInterface ni = e.nextElement();
        if (ni.getDisplayName().equals("wlp5s0"))
            isNixMashPC = formatMac(ni.getHardwareAddress()).equals("10-FE-ED-84-9E-A9");
} catch (SocketException e) {
...
ListparseInterfaceList(String s)
parse Interface List
List<NetworkInterface> interfaces = new ArrayList<NetworkInterface>(10);
if (s == null)
    return null;
StringTokenizer tok = new StringTokenizer(s, ",");
String interface_name;
NetworkInterface intf;
while (tok.hasMoreTokens()) {
    interface_name = tok.nextToken();
...
booleanpingFromInterface(String name)
ping From Interface
out.println("Pinging from interface " + name);
boolean connected = false;
NetworkInterface networkInterface = NetworkInterface.getByName(name);
if (networkInterface == null) {
    out.println("No network interface for " + name);
    return false;
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
...
Stringprint(Collection objs)
print
StringBuilder sb = new StringBuilder();
boolean first = true;
for (T obj : objs) {
    if (first)
        first = false;
    else
        sb.append(", ");
    sb.append(obj);
...
voidprintValidInterfaces(PrintWriter pout)
Prints out all the NetworkInterface names available on this machine as a list.
Enumeration<NetworkInterface> network_interfaces = NetworkInterface.getNetworkInterfaces();
while (network_interfaces.hasMoreElements()) {
    NetworkInterface net_if = network_interfaces.nextElement();
    pout.println("  " + net_if.getName());
NetworkInterfacetoNI(String niName)
Convert the property to a network interface
return NetworkInterface.getByName(niName);