大家知道Java中,有什么方法能得到计算机的MAC地址的方法 简单查了下jdk文档没找到相关api个人观点(仅供参考): 在java中调用其它语言的函数(方法) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我见过,记得好像是需要使用JNI调用本地ipconfig/all命令,然后写代码分析出返回的数据,从中得到MAC地址 JAVA里面是不能直接得到MAC的,只能通过调用原函数,比如C,C++帮助实现,楼上说得也是个方法 private static String getMacOnWindow() { String s = ""; try { String s1 = "ipconfig /all"; Process process = Runtime.getRuntime().exec(s1); BufferedReader bufferedreader = new BufferedReader( new InputStreamReader(process.getInputStream())); String nextLine; for (String line = bufferedreader.readLine(); line != null; line = nextLine) { nextLine = bufferedreader.readLine(); if (line.indexOf("Physical Address") <= 0) { continue; } int i = line.indexOf("Physical Address") + 36; s = line.substring(i); break; } bufferedreader.close(); process.waitFor(); } catch (Exception exception) { s = ""; } return s.trim(); } 不对前天我在csdn里面看到和如何获得mac地址不过忘记那个帖子了好像制止jdk里面有相关的函数 谢谢楼主提出的问题谢谢foolishidea(foolishidea)!! foolishidea(foolishidea)所说的是正确的!! foolishidea(foolishidea) 这个方法是可以得到服务器端的MAC地址。但是要得不到客房端的MAC地址。所以还请大家继续关心啊。谢谢!!!!! 十分感谢foolishidea(foolishidea)的程序代码!! 那在xNix上还要写相应的程序吗 为什么要加36? int i = line.indexOf("Physical Address") + 36; private static String getMacOnWindow() { String s = ""; try { String s1 = "netstar -e"; Process process = Runtime.getRuntime().exec(s1); BufferedReader bufferedreader = new BufferedReader( new InputStreamReader(process.getInputStream())); String nextLine; for (String line = bufferedreader.readLine(); line != null; line = nextLine) { nextLine = bufferedreader.readLine(); if (line.indexOf("Physical Address") <= 0) { continue; } int i = line.indexOf("Physical Address") + 36; s = line.substring(i); break; } bufferedreader.close(); process.waitFor(); } catch (Exception exception) { s = ""; } return s.trim(); } 登录后如何在不同页面判断已登录? 我想在我的jsp网页上出现一个这样的效果 希望前辈赐教!! 诚邀IT界精英加入此论坛,打造IT奇迹。 求ssh多对多的源代码包含CRUD操作的。给完结贴 tomcat自动删除文件问题 在线阅读问题 这是什么意思? Tomcat 5.0的 Bean驻留问题! EJB问题 select方法如何使用? 急~~~~关于java web service的发布的问题 如果没有submit动作就不会执行action吗?
String s = "";
try {
String s1 = "ipconfig /all";
Process process = Runtime.getRuntime().exec(s1);
BufferedReader bufferedreader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String nextLine;
for (String line = bufferedreader.readLine(); line != null; line = nextLine) {
nextLine = bufferedreader.readLine();
if (line.indexOf("Physical Address") <= 0) {
continue;
}
int i = line.indexOf("Physical Address") + 36;
s = line.substring(i);
break;
} bufferedreader.close();
process.waitFor();
} catch (Exception exception) {
s = "";
}
return s.trim();
}
前天我在csdn里面看到和如何获得mac地址
不过忘记那个帖子了
好像制止jdk里面有相关的函数
谢谢foolishidea(foolishidea)!!
int i = line.indexOf("Physical Address") + 36;
String s = "";
try {
String s1 = "netstar -e";
Process process = Runtime.getRuntime().exec(s1);
BufferedReader bufferedreader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String nextLine;
for (String line = bufferedreader.readLine(); line != null; line = nextLine) {
nextLine = bufferedreader.readLine();
if (line.indexOf("Physical Address") <= 0) {
continue;
}
int i = line.indexOf("Physical Address") + 36;
s = line.substring(i);
break;
} bufferedreader.close();
process.waitFor();
} catch (Exception exception) {
s = "";
}
return s.trim();
}