listnifs.java

来自「JAVA 工作指南 可以说是程序员必备的东西哦」· Java 代码 · 共 27 行

JAVA
27
字号
import java.io.*;import java.net.*;import java.util.*;import static java.lang.System.out;public class ListNIFs {    public static void main(String args[]) throws SocketException {        Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();                for (NetworkInterface netIf : Collections.list(nets)) {            out.printf("Display name: %s\n", netIf.getDisplayName());            out.printf("Name: %s\n", netIf.getName());            displaySubInterfaces(netIf);            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());        }     }}  

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?