50,523
社区成员
发帖
与我相关
我的任务
分享
File f=new File("F:\info.txt");
if(!f.exists){
create....
}
String commandText = "cmd >F:\info.txt";
Runtime.getRuntime().exec(commandText);
这样你的sysinfo信息就存在了你的F盘下的info.txt文件中
然后通过InputStream...
读取到你的程序就可以了。
上面就是大概的代码,个别API记不清了,你查一下,就是这个思路。String commandText = "cmd /c systeminfo";
try {
Process process = Runtime.getRuntime().exec(commandText);
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
把系统的配置信息都打到控制台了,我要用其中的一条,比如System Type: X86-based PC,怎么写,本人新手Process process = Runtime.getRuntime().exec( "这里写命令");
还是参考一下:http://blog.csdn.net/legendmohenote/article/details/5828455 Properties props=System.getProperties();
System.out.println("操作系统的版本:"+props.getProperty("os.version"));
System.out.println("操作系统的名称:"+props.getProperty("os.name"));
System.out.println("操作系统的构架:"+props.getProperty("os.arch"));
System.out.println("操作系统的版本:"+props.getProperty("os.version"));
Properties prop = System.getProperties();
String os = prop.getProperty("os.name");
System.out.println(os);