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 是什么格式,这个你自己转一下吧,信息都有了
import javanetInetAddress;
import javanetNetworkInterface;
import javanetSocketException;
import javanetUnknownHostException;
/
物理地址是48位,别和ipv6搞错了
/
public class LOCALMAC {
/
@param args
@throws UnknownHostException
@throws SocketException
/
public static void main(String[] args) throws UnknownHostException, SocketException {
// TODO Auto-generated method stub
//得到IP,输出PC-201309011313/1222067383
InetAddress ia = InetAddressgetLocalHost();
Systemoutprintln(ia);
getLocalMac(ia);
}
private static void getLocalMac(InetAddress ia) throws SocketException {
// TODO Auto-generated method stub
//获取网卡,获取地址
byte[] mac = NetworkInterfacegetByInetAddress(ia)getHardwareAddress();
Systemoutprintln("mac数组长度:"+maclength);
StringBuffer sb = new StringBuffer("");
for(int i=0; i<maclength; i++) {
if(i!=0) {
sbappend("-");
}
//字节转换为整数
int temp = mac[i]&0xff;
String str = IntegertoHexString(temp);
Systemoutprintln("每8位:"+str);
if(strlength()==1) {
sbappend("0"+str);
}else {
sbappend(str);
}
}
Systemoutprintln("本机MAC地址:"+sbtoString()toUpperCase());
}
}
UUID uuid=UUIDrandomUUID();
Systemoutprintln(uuidtoString());
UUID含义是通用唯一识别码 (Universally Unique Identifier),这 是一个软件建构的标准,也是被开源软件基金会 (Open Software Foundation, OSF) 的组织应用在分布式计算环境 (Distributed Computing Environment, DCE) 领域的一部分。
以上就是关于JAVA自动运行后,可收集系统的如下相关信息并保存到一个xml中: 1 硬件信息 cpu型号 内存大小 显卡信息等全部的内容,包括:JAVA自动运行后,可收集系统的如下相关信息并保存到一个xml中: 1 硬件信息 cpu型号 内存大小 显卡信息等、java中怎么获取电脑的mac地址、java怎么获取电脑的唯一标识等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)