求助如何获得本机的MAC地址 不知道要怎么获得本机的MAC地址,请教各位高手。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我的bloghttp://www.blogjava.net/qiyadeng/articles/14625.html 查查以前的帖子有过回答的也可以参考这里http://forum.java.sun.com/thread.jspa?threadID=655913 打开开始>程序>附件 命令提示符 输入arp -a 另外,这不是什么技术.你在google里面直接输入mac查找中文网站估计就找得到结果 给你一个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(); } } }} jdk1.4下没有ProcessBuilder类 不过可以通过Runtime的exec方法执行 基本原理一样 呵呵 我忘了说了,我的意思是用java来获得MAC地址了。crazycy(崔毅) ,谢谢你的程序。 关于ClearCase的使用 谁有jxta-netmap项目的源文件和文档 是不是Java中的Bug? applet初始化问题!简单 菜鸟问题之HelloWorld 极简单!包里能不能用interface JAVA中对XML文件处理的教程哪儿有? 哪位有ECC(椭圆曲线密码算法)的实现呀,不胜感激? 继承中的成员从新定义的问题 请教JAVA字符比较问题谢谢 看哪位高手能解决这个问题:servlet中的socket问题。 碰到的一个java端口通信的问题!急,大虾帮忙
http://www.blogjava.net/qiyadeng/articles/14625.html
有过回答的
也可以参考这里
http://forum.java.sun.com/thread.jspa?threadID=655913
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();
}
}
}
}
crazycy(崔毅) ,谢谢你的程序。