import
static
java.lang.System.out;
import
java.io.*;
import
java.net.*;
import
java.net.NetworkInterface;
import
java.util.*;
public
class
GFG {
public
static
void
main(String args[])
throws
SocketException
{
Enumeration<NetworkInterface> nets
= NetworkInterface.getNetworkInterfaces();
for
(NetworkInterface netInf :
Collections.list(nets)) {
out.printf(
"Display name: %s\n"
,
netInf.getDisplayName());
out.printf(
"Name: %s\n"
, netInf.getName());
displaySubInterfaces(netInf);
out.printf(
"\n"
);
}
}
static
void
displaySubInterfaces(NetworkInterface netIf)
throws
SocketException
{
Enumeration<NetworkInterface> subIfs
= netIf.getSubInterfaces();
for
(NetworkInterface subIf : Collections.list(subIfs)) {
out.printf(
"\tSub Interface Display name: %s\n"
,
subIf.getDisplayName());
out.printf(
"\tSub Interface Name: %s\n"
,
subIf.getName());
}
}
}