求助如何获得本机的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(崔毅) ,谢谢你的程序。 File类也许用的到 求JAVA运算程序源码. java中继承有什么缺点 GUI问题 Comparable接口中的comareTO()与Comparator接口中的compare()的区别 大家好帮我看一下面的定义包的程序中出现在的错误。 两个JAVA小问题 “C/JAVA爱好者”群,号码:3433906 欢迎加入 紧急求助 怎样在两个程序中实现共用同一个文件(包括写)?高分相赠! 看哪位高手能解决这个问题: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(崔毅) ,谢谢你的程序。