List of utility methods to do Network Interface Get
boolean | isNixMashPC() 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) { ... |
List | parseInterfaceList(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(); ... |
boolean | pingFromInterface(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(); ... |
String | print(CollectionStringBuilder sb = new StringBuilder(); boolean first = true; for (T obj : objs) { if (first) first = false; else sb.append(", "); sb.append(obj); ... |
void | printValidInterfaces(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()); |
NetworkInterface | toNI(String niName) Convert the property to a network interface return NetworkInterface.getByName(niName);
|