java jsp 获取电脑MAC地址
来源:互联网 发布:中国防火墙 知乎 编辑:程序博客网 时间:2024/05/17 01:18
package filters;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
public class GetMACAddress {
public String getMACAddress(String ipAddress) {
String str = "", strMAC = "", macAddress = "";
try {
Process pp = Runtime.getRuntime().exec("nbtstat -a " + ipAddress);
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) {
strMAC = str.substring(str.indexOf("MAC Address") + 14,
str.length());
break;
}
}
}
} catch (IOException ex) {
return "Can't Get MAC Address!";
}
//
if (strMAC.length() < 17) {
return "Error!";
}
macAddress = strMAC.substring(0, 2) + ":" + strMAC.substring(3, 5)
+ ":" + strMAC.substring(6, 8) + ":" + strMAC.substring(9, 11)
+ ":" + strMAC.substring(12, 14) + ":"
+ strMAC.substring(15, 17);
//
return macAddress;
}
public static void main(String[] args) {
GetMACAddress getMACAddress = new GetMACAddress();
System.out.println(getMACAddress.getMACAddress("192.168.0.100")); // 获得该ip地址的mac地址
}
public static String procAll(String str) {
return procStringEnd(procFirstMac(procAddress(str)));
}
public static String procAddress(String str) {
int indexof = str.indexOf("Physical Address");
if (indexof > 0) {
return str.substring(indexof, str.length());
}
return str;
}
public static String procFirstMac(String str) {
int indexof = str.indexOf(":");
if (indexof > 0) {
return str.substring(indexof + 1, str.length()).trim();
}
return str;
}
public static String procStringEnd(String str) {
int indexof = str.indexOf("\r");
if (indexof > 0) {
return str.substring(0, indexof).trim();
}
return str;
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
public class GetMACAddress {
public String getMACAddress(String ipAddress) {
String str = "", strMAC = "", macAddress = "";
try {
Process pp = Runtime.getRuntime().exec("nbtstat -a " + ipAddress);
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) {
strMAC = str.substring(str.indexOf("MAC Address") + 14,
str.length());
break;
}
}
}
} catch (IOException ex) {
return "Can't Get MAC Address!";
}
//
if (strMAC.length() < 17) {
return "Error!";
}
macAddress = strMAC.substring(0, 2) + ":" + strMAC.substring(3, 5)
+ ":" + strMAC.substring(6, 8) + ":" + strMAC.substring(9, 11)
+ ":" + strMAC.substring(12, 14) + ":"
+ strMAC.substring(15, 17);
//
return macAddress;
}
public static void main(String[] args) {
GetMACAddress getMACAddress = new GetMACAddress();
System.out.println(getMACAddress.getMACAddress("192.168.0.100")); // 获得该ip地址的mac地址
}
public static String procAll(String str) {
return procStringEnd(procFirstMac(procAddress(str)));
}
public static String procAddress(String str) {
int indexof = str.indexOf("Physical Address");
if (indexof > 0) {
return str.substring(indexof, str.length());
}
return str;
}
public static String procFirstMac(String str) {
int indexof = str.indexOf(":");
if (indexof > 0) {
return str.substring(indexof + 1, str.length()).trim();
}
return str;
}
public static String procStringEnd(String str) {
int indexof = str.indexOf("\r");
if (indexof > 0) {
return str.substring(0, indexof).trim();
}
return str;
}
}
- java jsp 获取电脑MAC地址
- C# 获取电脑MAC地址
- 获取电脑的MAC地址
- java获取电脑主板、CPU 编号以及MAC地址
- Java获取MAC地址
- java 获取mac地址
- java获取Mac地址
- java 获取mac地址
- java获取mac地址
- java获取mac地址
- Java获取MAC地址
- Java 获取mac 地址
- java 获取MAC地址
- java 获取MAC地址
- Java获取Mac地址
- java 获取mac地址
- java获取Mac地址
- JS获取MAC地址(电脑物理地址)
- MyEclpese异常信息
- maven为不同环境打包(hibernate)
- WCF的配置文件的baseAddress的真正含义
- Aptana JQuery代码提示
- shell脚本----读取一个文本文件将内容按行保存成数组变量
- java jsp 获取电脑MAC地址
- Android绘图基础:Canvas、Paint等的使用
- JS Select 选项清空
- 用ldd查看C++程序的依赖库
- C算法第一卷(第三版)纠错
- 解析HTML最灵活的Java组件
- 关于父亲放水果pv原语的题目
- PCB Layout的习惯设置及常见问题解答----文章收集
- 下拉刷新