Complete Code:
/**
* This is Template 1 workplace
*/
import java.net.*;
import java.util.Collections;
//import java.util.Date;
import java.util.Enumeration;
import java.io.*;
import static java.lang.System.out;
/**
* @author Manas9
*
*/
public class ClassTemplate1 {
/**
*
*/
public ClassTemplate1() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args) throws IOException
{
Enumeration<NetworkInterface> enumNets =
NetworkInterface.getNetworkInterfaces();
for (NetworkInterface intInterface : Collections.list(enumNets))
displayNetworkInterface(intInterface);
}
static void displayNetworkInterface(NetworkInterface pIntreface) throws
SocketException {
out.printf("Interface device name: %s\n", pIntreface.getDisplayName());
out.printf("Interface Name: %s\n", pIntreface.getName());
Enumeration<InetAddress> inetAddresses = pIntreface.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
out.printf("InetAddress ext: %s\n", inetAddress);
}
out.printf("\n");
}
}
|