提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
列出计算机上可用的网络接口
import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; /**来 自 N o w J a v a . c o m - 时 代 Java**/ public class Main { public static void main(String[] args) { try { Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); while (e.hasMoreElements()) { NetworkInterface nif = e.nextElement(); System.out.println("Name: " + nif.getName() + ", Supports Multicast: " + nif.supportsMulticast() + ", isUp(): " + nif.isUp()) ; }