我可以使用下面的代碼如何查找遠程系統的MAC地址
package com.eiw.server;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
class FindMACAddress {
public static void main(String[] args) {
InetAddress ip;
try {
ip = InetAddress.getLocalHost();
System.out.println("The mac Address of this machine is :"
+ ip.getHostAddress());
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
byte[] mac = network.getHardwareAddress();
System.out.print("The mac address is : ");
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());
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (SocketException e) {
e.printStackTrace();
}
}
}
得到本地MAC地址,但我需要找到遠程系統的MAC地址... 是否有可能?我已經通過了一些帖子......但不清楚....
可能重複[?如何排除從Log4j的記錄器/追加程序的單一類] (http://stackoverflow.com/questions/5270052/how-to-exclude-a-single-class-from-a-log4j-logger-appender) – Raedwald
我不認爲這是重複 – DThought
可能重複[查詢ARP緩存獲取MAC ID](http:// stackoverflow .com/questions/1238963/query-arp-cache-to-get-mac-id) – reto