java简单的获取windows系统网卡mac地址
2010-09-14 02:31
639 查看
package com.youkone.tool;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class MACAddress {
public MACAddress() {
}
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(""+MACAddress.getMACAddress());
}
}
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class MACAddress {
public MACAddress() {
}
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(""+MACAddress.getMACAddress());
}
}
相关文章推荐
- java简单的获取windows系统网卡mac地址
- java简单的获取windows系统网卡mac地址
- java简单的获取windows系统网卡mac地址
- java简单的获取windows系统网卡mac地址
- java简单的获取windows系统网卡mac地址
- java执行系统命令,获取网卡物理地址
- java获取网卡MAC地址
- 【转】java:多网卡环境下获取MAC地址
- 关于获取系统信息,CPUID,硬盘ID,网卡MAC地址的VS2008实现
- Java获取CPU序列号和网卡Mac地址
- 获取linux系统电脑网卡mac地址
- PL/SQL调用JAVA获取网卡MAC地址
- java 获取本机的所有网卡的Mac地址
- windows系统获取mac地址命令
- Windows在没有TCP/IP协议的情况下获取网卡MAC地址
- java获取当前操作系统名称以及各系统的本机网卡地址
- java获取网卡的mac地址
- windows及Linux系统下获取IP及MAC地址的方法
- vbs Windows系统改变或修改网卡的MAC地址的脚本与软件第1/2页
- Windows下Java如何调用本地获取mac地址