利用Java,怎样获得指定IP的对应的MAC地址

2025-01-20 03:53:32
推荐回答(1个)
回答1:

import java.net.*;
public class NetInfo {
public static void main(String[] args) {
new NetInfo().say();
}
public void say() {
try {
InetAddress i = InetAddress.getLocalHost();
System.out.println(i); //计算机名称和ip
System.out.println(i.getHostName()); //名称
System.out.println(i.getHostAddress()); //只获得ip
}
catch(Exception e){e.printStackTrace();}
}
}