不知道要怎么获得本机的MAC地址,请教各位高手。

解决方案 »

  1.   

    我的blog
    http://www.blogjava.net/qiyadeng/articles/14625.html
      

  2.   

    查查以前的帖子
    有过回答的
    也可以参考这里
    http://forum.java.sun.com/thread.jspa?threadID=655913
      

  3.   

    打开开始>程序>附件 命令提示符 输入arp -a
      

  4.   

    另外,这不是什么技术.你在google里面直接输入mac查找中文网站估计就找得到结果
      

  5.   

    给你一个jdk5.0下的例子:
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.List;public class ProcessBuilderDemo {
    public static void main(String[] args) {
    //Physical Address. . . . . . . . . :
    InputStream input = null;
    try{
    //执行命令
    ProcessBuilder builder = new ProcessBuilder("ipconfig" ,"/all");
    Process process = builder.start();
    input = process.getInputStream();

    //把得到的流得到
    byte[] b = new byte[1024];
    StringBuffer buffer = new StringBuffer();
    while (input.read(b) > 0) {
    buffer.append(new String(b));
    }

    //分析流
    String value = buffer.substring(0);
    String systemFlag = "Physical Address. . . . . . . . . :";
    int index = value.indexOf(systemFlag);
    List<String> address = new ArrayList<String>();
    if (0 < index) {
    value = buffer.substring(index + systemFlag.length());
    address.add(value.substring(0, 18));
    } //打印输出
    for (String add : address) {
    System.out.println(add);
    }
    } catch (Exception ex) {
    ex.printStackTrace();
    } finally {
    try {
    input.close();
    }
    catch (IOException ex) {
    ex.printStackTrace();
    }
    }
    }
    }
      

  6.   

    jdk1.4下没有ProcessBuilder类 不过可以通过Runtime的exec方法执行 基本原理一样 呵呵
      

  7.   

    我忘了说了,我的意思是用java来获得MAC地址了。
    crazycy(崔毅) ,谢谢你的程序。