有哪些类获取系统的信息如系统名称、ip、用户名等??? 用InetAddress.getLocalHost可得ip、用InetAddress.getByName可得机器名系统名称和版本、用户名、MAC地址用什么方法得到啊??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 System.getProperty("os.name");System.getProperty("os.version");System.getProperty("user.name");可以得到前3项,对于MAC地址,用调用本地进程“ipconfig/all”或取输出 得到以 "Physical Address" 为开头一行,解吸:后面的内容就可以了 只是针对win2000等版本,别的不知道行不行。 谢谢hvv!我用下面的语句可以得到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); } }} 这样可以得到所有的望卡号,注意有可能不是一个,比如我的机器上旧有3个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); } }} 帮忙看看错 如何使用监听器实现画图 谁知道JDK5自带的log和log4j哪个更好? 想要转移一个多级目录,而且要保证目录路径的一致性,请问大侠应该怎么作啊? 谁有CSS+DIV 布局资料 java I/O问题 Jcreator Pro的一个小问题 有关网页的安全问题 给定2个时间,如何计算他们之间的天数? 帮我瞧瞧!!!!谢谢了 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);
}
}
}