更新时间:2021-10-15 22:43:56
使用Java 6+,您可以使用 NetworkInterface.getHardwareAddress
。
With Java 6+, you can use NetworkInterface.getHardwareAddress
.
请记住,计算机可以没有网卡,特别是如果它是嵌入式或虚拟的。它也可以有多个。您可以使用 NetworkInterface.getNetworkInterfaces()
。
Bear in mind that a computer can have no network cards, especially if it's embedded or virtual. It can also have more than one. You can get a list of all network cards with NetworkInterface.getNetworkInterfaces()
.