listnets.java

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

JAVA
23
字号
import java.io.*;import java.net.*;import java.util.*;import static java.lang.System.out;public class ListNets {    public static void main(String args[]) throws SocketException {        Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();        for (NetworkInterface netint : Collections.list(nets))            displayInterfaceInformation(netint);    }    static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {        out.printf("Display name: %s\n", netint.getDisplayName());        out.printf("Name: %s\n", netint.getName());        Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();        for (InetAddress inetAddress : Collections.list(inetAddresses)) {            out.printf("InetAddress: %s\n", inetAddress);        }        out.printf("\n");     }}  

⌨️ 快捷键说明

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