JAVA自动运行后,可收集系统的如下相关信息并保存到一个xml中: 1 硬件信息 cpu型号 内存大小 显卡信息等

JAVA自动运行后,可收集系统的如下相关信息并保存到一个xml中: 1 硬件信息 cpu型号 内存大小 显卡信息等,第1张

public void getHardwareInfo() {
        Runtime r = RuntimegetRuntime();
        Systemoutprintln("CPU信息:");
        Systemoutprint("数量:" + ravailableProcessors() + "\n");
        Systemoutprintln(SystemgetProperty("suncpuisalist"));
        Systemoutprintln("内存:");
        Systemoutprintln("total: " + rtotalMemory() + " bytes");
        Systemoutprintln("left: " + rfreeMemory() + " bytes");
    }
                                                  
    public void getSoftwareInfo() {
        Systemoutprintln(" *** 作系统:");
        Systemoutprint(SystemgetProperty("osname") + " ");
        Systemoutprint(SystemgetProperty("sunospatchlevel") + " ");
        Systemoutprint(SystemgetProperty("osversion") + " ");
        Systemoutprintln(SystemgetProperty("osarch"));
        Systemoutprint("用户名:" + SystemgetProperty("username") + "\n");
    }
                                                  
    public void getExtraInfo() throws SocketException, UnknownHostException {
        Systemoutprint("时区:");
        Systemoutprintln(SystemgetProperty("usertimezone"));
        Systemoutprintln("网卡:");
        Enumeration<NetworkInterface> interfaces = NetworkInterfacegetNetworkInterfaces();
        while(interfaceshasMoreElements()) {
            NetworkInterface netInterface = interfacesnextElement();
            Systemoutprintln(netInterfacegetDisplayName());
            Enumeration<InetAddress> ips = netInterfacegetInetAddresses();
            if(ips != null) {
                if(ipshasMoreElements()) {
                    InetAddress ia = ipsnextElement();
                    if(ia != null) {
                        Systemoutprintln("ip: " + InetAddressgetByAddress(iagetAddress()));
                    }
                }
            }
        }
    }

不知道你要的 xml 是什么格式,这个你自己转一下吧,信息都有了

以上就是关于JAVA自动运行后,可收集系统的如下相关信息并保存到一个xml中: 1 硬件信息 cpu型号 内存大小 显卡信息等全部的内容,包括:JAVA自动运行后,可收集系统的如下相关信息并保存到一个xml中: 1 硬件信息 cpu型号 内存大小 显卡信息等、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/10061459.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-04
下一篇 2023-05-04

发表评论

登录后才能评论

评论列表(0条)

保存