如何获得网卡信息 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 获得 网卡MACimport java.io.*;import java.net.InetAddress;public class GetMac{ //通过IP获取网卡地址 public String getMacByIP(String serverIP) { String str = ""; String macAddress = ""; try { Process pp = Runtime.getRuntime().exec("nbtstat -A "+serverIP); 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) { ex.printStackTrace(); } return macAddress; } //通过机器名获取网卡地址 public String getMacByServerName(String serverName) { String str = ""; String macAddress = ""; try { Process pp = Runtime.getRuntime().exec("nbtstat -a "+serverName); 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) { ex.printStackTrace(); } return macAddress; } public static void main(String[] args) { try { GetMac getmac; getmac=new GetMac(); String mac=""; mac=getmac.getMacByIP("192.168.1.57"); System.out.println(mac); mac=getmac.getMacByServerName("server"); System.out.println(mac); } catch( Exception e ) { System.out.println( e.getMessage() ); } }} 读取文件问题(java编程思想中BufferedInputFile) java问题 关于运行.jar文件的问题 大家帮帮忙..我毕业设计要一购物网站.....给我源码的给RMB 为什么会抛出java.io.FileNotFoundException哪,路径是对的啊,各位高人帮帮忙啊 请问如何把一个字节数组(内容为ASCII字符)转换为一个字符串? 获取窗口的分辨率 安卓中写在oncreat里的一位数组怎么被引用 为什么用RMIC编译类,老是找不到该类啊 我的java怎么会这样? 怎样建立JDBC连接 JAVA 高手进. JDK1.4 和 JDK1.5在输出的编码方式有什么不一样吗??
import java.io.*;
import java.net.InetAddress;public class GetMac
{
//通过IP获取网卡地址
public String getMacByIP(String serverIP)
{
String str = "";
String macAddress = "";
try
{
Process pp = Runtime.getRuntime().exec("nbtstat -A "+serverIP);
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)
{
ex.printStackTrace();
}
return macAddress;
}
//通过机器名获取网卡地址
public String getMacByServerName(String serverName)
{
String str = "";
String macAddress = "";
try
{
Process pp = Runtime.getRuntime().exec("nbtstat -a "+serverName);
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)
{
ex.printStackTrace();
}
return macAddress;
}
public static void main(String[] args)
{
try
{ GetMac getmac;
getmac=new GetMac();
String mac="";
mac=getmac.getMacByIP("192.168.1.57");
System.out.println(mac);
mac=getmac.getMacByServerName("server");
System.out.println(mac);
}
catch( Exception e )
{
System.out.println( e.getMessage() );
}
}
}