获取Mac地址
2014-05-07 00:12
134 查看
/**
* 获取Mac地址
* @return
*/
public static String getMacAddress()
{
String mac = "";
String line = "";
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()));
while((line = br.readLine()) != null)
{
if (line.indexOf("Physical Address") > 0)
{
int index = line.indexOf(":") + 2;
mac = line.substring(index);
break;
}
}
br.close();
} catch (IOException e) {}
}
return mac;
}
* 获取Mac地址
* @return
*/
public static String getMacAddress()
{
String mac = "";
String line = "";
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()));
while((line = br.readLine()) != null)
{
if (line.indexOf("Physical Address") > 0)
{
int index = line.indexOf(":") + 2;
mac = line.substring(index);
break;
}
}
br.close();
} catch (IOException e) {}
}
return mac;
}
相关文章推荐
- java获取mac地址-屏蔽ip封mac地址
- Android 6.0获取MAC地址
- java获取mac地址-屏蔽ip封mac地址
- C++获取本机MAC地址
- http 获取mac地址
- 基于ARP协议获取局域网内主机MAC地址
- C# 获取IP和MAC地址
- VC实现获取本机MAC地址的方法
- android设备无线、有线网络下获取MAC地址
- 用C#获取硬盘序列号,CPU序列号,网卡MAC地址的源码
- C#获取IP与MAC地址
- ASP.NET获取客户端IP及MAC地址
- C#编程之 如何获取本地和远程主机的IP及MAC地址
- 利用正则表达式获取MAC地址
- 获取cpu序列号,硬盘ID,网卡MAC地址
- 实用代码-C#获取本机网络适配器信息及MAC地址
- Android手机获取Mac地址的方法
- ASP.NET获取IP与MAC地址的方法
- 通过WDK获取网卡原生MAC地址和当前MAC地址
- MAC扫描器--轻松获取大批量网卡MAC地址