1
私はクライアントのMACアドレスを取得したい、javaからipの詳細。JavaからクライアントのMACアドレスを取得することは可能ですか?
私は以下のプログラムを試してみました。しかし、それはサーバーのIP詳細だけを示しています。
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) ? "-" : ""));
}
クライアントのMAC IDの詳細にアクセスしたいと思います。
Javaコードはサーバーで実行されるため、サーバーのMACアドレスを取得します。あなたはクライアントの情報を得るために要求オブジェクトに取り組む必要があります – SpringLearner