高手们!请问JAVA中如何获取主机MAC地址呢? 高手们!请问JAVA中如何获取主机MAC地址呢?如果知道的能否指点一二。谢谢了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.io.*;public class getMAC { 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); } } br.close(); System.out.println(address.trim()); } catch (IOException e) { } } return address;}public static void main(String[] args) { getMAC getmac; getmac=new getMAC(); String f=getmac.getMACAddress(); //System.out.println(f); }}看看,这样一个行不行,我写的 求解JAVA string.getBytes()问题。。 java.nio 今天刚做个了nio的小demo 发现传输速度特别慢......如何解决。。那位高手指点下。只是传输byte【】过去 我用JAVA和JSP做了个软件,怎么把加入涵数右键的 正式表达式的问题? 继承和组合的关系 如何访问WEB SERVICE? 郁闷ing,散分 小妹问个初级问题,别笑呀!~! 大家帮帮我。谢谢。 Map支持order吗?支持duplicate吗? 这两句代码有什么不同? jdbc问题,为什么找不到类库
public class getMAC
{
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);
}
}
br.close();
System.out.println(address.trim());
}
catch (IOException e) { }
}
return address;
}
public static void main(String[] args)
{
getMAC getmac;
getmac=new getMAC();
String f=getmac.getMACAddress();
//System.out.println(f); }
}
看看,这样一个行不行,我写的