w10检测java版本_如何在Java中检查Windows版本?

该博客展示了如何使用Java代码调用Windows命令`systeminfo`来检测并解析操作系统的版本信息,特别是针对Windows 10的版本检测。通过运行Java程序,可以获取到如‘Basic’, ‘Home’, ‘Professional’, 或 ‘Enterprise’等Windows版本。" 115992629,10538000,一维离散小波变换DWT的Mallat算法C++和MATLAB实现解析,"['小波分析', '信号处理', 'MATLAB编程', 'C++编程', '数值计算']
摘要由CSDN通过智能技术生成

您可以随时使用Java调用Windows命令“systeminfo”,然后解析出结果,我似乎无法找到一种在Java中本地实现的方法.

import java.io.*;

public class GetWindowsEditionTest

{

public static void main(String[] args)

{

Runtime rt;

Process pr;

BufferedReader in;

String line = "";

String sysInfo = "";

String edition = "";

String fullOSName = "";

final String SEARCH_TERM = "OS Name:";

final String[] EDITIONS = { "Basic", "Home",

"Professional", "Enterprise" };

try

{

rt = Runtime.getRuntime();

pr = rt.exec("SYSTEMINFO");

in = new BufferedReader(new InputStreamReader(pr.getInputStream()));

//add all the lines into a variable

while((line=in.readLine()) != null)

{

if(line.contains(SEARCH_TERM)) //found the OS you are using

{

//extract the full os name

fullOSName = line.substring(line.lastIndexOf(SEARCH_TERM)

+ SEARCH_TERM.length(), line.length()-1);

break;

}

}

//extract the edition of windows you are using

for(String s : EDITIONS)

{

if(fullOSName.trim().contains(s))

{

edition = s;

}

}

System.out.println("The edition of Windows you are using is "

+ edition);

}

catch(IOException ioe)

{

System.err.println(ioe.getMessage());

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值