- 论坛徽章:
- 0
|
一个例子,windows下的,这也是转发的
//通过IP获取网卡地址
private String getMacAddressIP(String remotePcIP)
{
String str="";
String macAddress="";
try
{
Process pp= Runtime.getRuntime().exec ("nbtstat -A " + remotePcIP);
InputStreamReader ir = new InputStreamReader(pp.getInputStream());
LineNumberReader input = new LineNumberReader (ir);
for (int i = 1; i <100; i++)
{
str=input.readLine();
if (str!=null)
{
if(str.indexOf("MAC Address")>1)
{
macAddress=str.substring(str.indexOf("MAC Address")+14,str.length());
break;
}
}
}
}
catch (IOException ex) {}
return macAddress;
} |
|