struts MAC 在做一个系统,用户只能在绑定的MAC地址的机器上登录系统使用系统 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.IOException;/** * <p>Title: </p> * * <p>Description: </p> * * <p>Copyright: Copyright (c) 2006</p> * * <p>Company: </p> * * @author not attributable * @version 1.0 */public class macfind{ public macfind() { } public static String getMACAddress() { String address = ""; String os = System.getProperty("os.name"); if (os != null && os.startsWith("Windows")) { try { String command = "cmd.exe /c ipconfig /all"; Process p = Runtime.getRuntime().exec(command); BufferedReader br = new BufferedReader( new InputStreamReader(p.getInputStream())); String line; while ((line = br.readLine()) != null) { if (line.indexOf("Physical Address") > 0) { int index = line.indexOf(":"); index += 2; address = line.substring(index); break; } } br.close(); return address.trim(); } catch (IOException e) {} } return address; } public static void main(String[] args) { System.out.println(""+macfind.getMACAddress());}}供参考 Java的api中没有可以直接获得物理地址的功能,目前只能通过dos命令行来获取地址 那用这个方式的话,也只能是得到本机的MAC,并不是远程机的请求机器的MAC JDBC Connection 多线程 痛苦中,javaMail收发邮件问题 JSP权限控制? 运行web后出现空指针异常,有谁能帮我看看 如何在其它机器上获取tomcat6服务器上的JNDI资源 这是面试时候碰到一个题目,大家看看怎么解决?? 为什么这个简单的AOP不能再spring2.0.5下运行,在1.2.9下正常 Struts: Action得不到页面Form中动态数据的问题! 大家帮我看看weblogic 上这个数据库连接池的抱错是怎么回事? 用jsp连EJB怎么也连不上了!!!大侠帮忙啊!!!(JBulider9+Weblogic8.1) struts标签 jsp页面权限
import java.io.InputStreamReader;
import java.io.IOException;/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class macfind{
public macfind() {
} public static String getMACAddress() { String address = "";
String os = System.getProperty("os.name");
if (os != null && os.startsWith("Windows")) {
try {
String command = "cmd.exe /c ipconfig /all";
Process p = Runtime.getRuntime().exec(command);
BufferedReader br =
new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
if (line.indexOf("Physical Address") > 0) {
int index = line.indexOf(":");
index += 2;
address = line.substring(index);
break;
}
}
br.close();
return address.trim();
} catch (IOException e) {}
}
return address;
} public static void main(String[] args) {
System.out.println(""+macfind.getMACAddress());
}
}
供参考