小编sun*_*nny的帖子

在java中使用IP地址查找mac地址

public static void main(String[] args) {
    try {
        InetAddress address = InetAddress.getLocalHost();
        // InetAddress address = InetAddress.getByName("192.168.46.53");

        /*
         * Get NetworkInterface for the current host and then read the
         * hardware address.
         */
        NetworkInterface ni = NetworkInterface.getByInetAddress(address);
        if (ni != null) {
            byte[] mac = ni.getHardwareAddress();
            if (mac != null) {
                /*
                 * Extract each array of mac address and convert it to hexa with the
                 * following format 08-00-27-DC-4A-9E.
                 */
                for (int i = 0; i < mac.length; i++) …
Run Code Online (Sandbox Code Playgroud)

java sockets url

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

sockets ×1

url ×1