Examples of NetInterfaceObject


Examples of systeminformationmonitor.system.object.NetInterfaceObject

        private NetInfoObject netInfoObj;
        private String networkName;

        public UpdateNetworkInformation(String networkName) {
            this.networkName = networkName;
            this.netInterface = new NetInterfaceObject();
            this.netInfoObj = new NetInfoObject();
        }
View Full Code Here

Examples of systeminformationmonitor.system.object.NetInterfaceObject

        try {
            Enumeration networks = NetworkInterface.getNetworkInterfaces();
            for (Object netint : Collections.list(networks)) {
                NetworkInterface netInterface = (NetworkInterface) netint;
                NetInterfaceObject netObj = new NetInterfaceObject();

                // get the name of the interface
                netObj.setName(netInterface.getDisplayName());

                if (netInterface.getInterfaceAddresses().size() >= 1) {
                    netList.add(netObj);
                }
            }
View Full Code Here

Examples of systeminformationmonitor.system.object.NetInterfaceObject

        return netList;
    }

    public static NetInterfaceObject getNetInfoObject(String interfaceName) {
        NetInterfaceObject netObj = new NetInterfaceObject();

        try {
            Enumeration networks = NetworkInterface.getNetworkInterfaces();
            for (Object netint : Collections.list(networks)) {
                NetworkInterface netInterface = (NetworkInterface) netint;

                if (interfaceName.equals(netInterface.getDisplayName())) {
                    // get the name of the interface
                    netObj.setName(netInterface.getDisplayName());
                    netObj.setIsVirtual(netInterface.isVirtual());

                    try {
                        // get the MAC address of the interface
                        netObj.setHardwareAddress(
                                netInterface.getHardwareAddress());
                        // test if the interface is up and running
                        netObj.setIsUp(netInterface.isUp());
                        netObj.setIsLoopback(netInterface.isLoopback());
                    } catch (SocketException ex) {
                        Logger.getLogger(
                                NetInterface.class.getName()).log(
                                Level.SEVERE, null, ex);
                    }

                    // get the IP addresses of this interface
                    Vector<String> ipVector = new Vector<String>();
                    Vector<String> hostNameVector = new Vector<String>();
                    Enumeration ipAddress = netInterface.getInetAddresses();
                    for (Object ipAdd : Collections.list(ipAddress)) {
                        InetAddress ip = (InetAddress) ipAdd;
                        ipVector.add(ip.getHostAddress());
                        hostNameVector.add(ip.getCanonicalHostName());
                    }

                    if (!ipVector.isEmpty()) {
                        // add the IP address
                        netObj.setIpAddress(ipVector.lastElement());
                    }
                    if (!hostNameVector.isEmpty()) {
                        // add the host name
                        netObj.setHostName(hostNameVector.lastElement());
                    }
                }
            }
        } catch (SocketException ex) {
            Logger.getLogger(NetInterface.class.getName()).log(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.