📄 systeminfo.java
字号:
/*
* $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/info/SystemInfo.java,v 1.6 2004/01/18 19:06:43 minhnn Exp $
* $Author: minhnn $
* $Revision: 1.6 $
* $Date: 2004/01/18 19:06:43 $
*
* ====================================================================
*
* Copyright (C) 2002-2004 by MyVietnam.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* All copyright notices regarding MyVietnam and MyVietnam CoreLib
* MUST remain intact in the scripts and source code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Correspondence and Marketing Questions can be sent to:
* info@MyVietnam.net
*
* @author: Minh Nguyen minhnn@MyVietnam.net
* @author: Mai Nguyen mai.nh@MyVietnam.net
*/
package net.myvietnam.mvncore.info;
public class SystemInfo {
private String vmName;
private String vmVendor;
private String vmVersion;
private String runtimeName;
private String runtimeVersion;
private String osName;
private String osVersion;
private String cpu;
long totalMemory = 0;
long freeMemory = 0;
long totalMemoryKB = 0;
long freeMemoryKB = 0;
public SystemInfo() {
vmName = getProperty("java.vm.name");
vmVendor = getProperty("java.vm.vendor");
vmVersion = getProperty("java.vm.version");
runtimeName = getProperty("java.runtime.name");
runtimeVersion = getProperty("java.runtime.version");
osName = getProperty("os.name");
osVersion = getProperty("os.version");
cpu = getProperty("sun.cpu.isalist");
Runtime runtime = Runtime.getRuntime();
totalMemory = runtime.totalMemory();
freeMemory = runtime.freeMemory();
totalMemoryKB = totalMemory/1024;
freeMemoryKB = freeMemory/1024;
}
public static String getProperty(String key) {
String retValue = null;
try {
retValue = System.getProperty(key, "");
} catch (Exception ex) {
retValue = "no access";
}
return retValue;
}
public String getCpu() {
return cpu;
}
public String getOsName() {
return osName;
}
public String getOsVersion() {
return osVersion;
}
public String getRuntimeName() {
return runtimeName;
}
public String getRuntimeVersion() {
return runtimeVersion;
}
public String getVmName() {
return vmName;
}
public String getVmVendor() {
return vmVendor;
}
public String getVmVersion() {
return vmVersion;
}
public long getFreeMemory() {
return freeMemory;
}
public long getFreeMemoryKB() {
return freeMemoryKB;
}
public long getTotalMemory() {
return totalMemory;
}
public long getTotalMemoryKB() {
return totalMemoryKB;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -