用InetAddress.getLocalHost可得ip、
用InetAddress.getByName可得机器名
系统名称和版本、用户名、MAC地址用什么方法得到啊???
用InetAddress.getByName可得机器名
系统名称和版本、用户名、MAC地址用什么方法得到啊???
解决方案 »
- JAVA connect被拒绝
- 什么是单立模式,代码实现 求 高手回答问题 非常急
- 如果在命令行中运行不同目录的类文件
- MyEclipser中配置Oracle9
- 请问:二维数组的问题,为什么会出现空指针异常的错误?
- DefaultRenderingErrorListener.errorOccurred:
- java接口的属性怎么声明?
- 郁闷,我为何装了j2sdk1.4.0之后,application 程序可以运行,但是为何就是没有java console ,而且在运行java applet 时只有框架,没有内容,
- 我的IE运行不了applet,怎么回事啊?(W2K,IE 6.0)
- java菜鸟问一个类似c++中vtable的问题
- jcreator和jdk
- jb7的控件设计问题
System.getProperty("os.version");
System.getProperty("user.name");
可以得到前3项,
对于MAC地址,用
调用本地进程“ipconfig/all”
或取输出 得到以 "Physical Address" 为开头一行,解吸:后面的内容就可以了
我用下面的语句可以得到
System.getProperty("os.name") -->操作系统名
System.getProperty("os.version")--》版本
System.getProperty("user.name")--》当前用户
InetAddress.getLocalHost().getHostAddress()--》ip地址
InetAddress.getLocalHost().getHostName()--->机器名
但我想用ipconfig/all里的全部信息
我用
try{
Runtime.getRuntime().exec("C:\\WINNT\\system32\\ipconfig.exe /all");
}
catch{
}
好象不执行ipconfig.exe /all,不知道有没有其它的办法?
如何可以执行ipconfig.exe /all,那么如何接受它的信息呢???
import java.io.*;
public class Ipcfg
{
public static void main(String [] args) throws Exception
{
Runtime r=Runtime.getRuntime();
Process p=r.exec("ipconfig /all");
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line=br.readLine())!=null)
{
System.out.println(line);
}
}
}
import java.io.*;
public class Ipcfg
{
public static void main(String [] args) throws Exception
{
Runtime r=Runtime.getRuntime();
Process p=r.exec("ipconfig /all");
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line=br.readLine())!=null)
{
if(line.trim().startsWith("Physical Address")){
int sp=line.indexOf(":");
System.out.println("network adapter"+line.substring(sp).trim());
}
//System.out.println(line);
}
}
}
import java.io.*;
public class Ipcfg
{
public static void main(String [] args) throws Exception
{
Runtime r=Runtime.getRuntime();
Process p=r.exec("ipconfig /all");
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line=br.readLine())!=null)
{
if(line.trim().startsWith("Physical Address")){
int sp=line.indexOf(":");
System.out.println("network adapter:"+line.substring(sp+1).trim());
}
//System.out.println(line);
}
}
}