Java Programming

Network Interface Info

Java programming example for get network interface information

10/28/2021
0 views
network-interface-info.javaJava
/* Get Network Interface details of the Local machine */
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;

public class networkParameter {
	public static void main(String args[]) throws SocketException {

		/* Collect network interface details */
		Enumeration<NetworkInterface> netInf = NetworkInterface.getNetworkInterfaces();
		for (NetworkInterface netInfo : Collections.list(netInf)) {

			/* Display network interface details */
			System.out.println("Display name: "+ netInfo.getDisplayName());
			System.out.println("Name: "+ netInfo.getName());
			Enumeration<InetAddress> ipAddresses = netInfo.getInetAddresses();
			for (InetAddress ipAddress : Collections.list(ipAddresses))
				System.out.println("IP Address: "+ inetAddress);
			System.out.println("\n");
		}
	}

}




/* Output */
Display name: eth0
Name: eth0
IP Address: /fe80:0:0:0:eea8:6bff:fef5:1e5f%eth0
IP Address: /192.168.1.1

Display name: lo
Name: lo
IP Address: /0:0:0:0:0:0:0:1%eth0
IP Address: /127.0.0.1
Java TutorialGet network interfaceNII

Loading comments...

Related Examples

Deliver breaking news, insightful commentary, and exclusive reports.

Targeting readers who rely on our platform to stay ahead of the curve.

Contact Us: benzingaheadlines@gmail.com