【发布时间】:2013-04-15 09:35:12
【问题描述】:
首先我像这样从pc客户端获取mac地址
public void getterMacAddress(){
InetAddress ip;
try {
ip = InetAddress.getLocalHost();
System.out.println("Current IP address : " + ip.getHostAddress());
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
byte[] mac = network.getHardwareAddress();
System.out.print("Current MAC address : ");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mac.length; i++) {
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
}
System.out.println(sb.toString());
macAddress = sb.toString();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (SocketException e){
e.printStackTrace();
}
}
我成功获取了mac地址,但是如何将mac地址发送到服务器?
【问题讨论】:
-
发送到服务器是什么意思。当您在服务器上部署应用程序时,它已经存在。你只需要阅读它