系统环境相关 主要是系统属性信息的key @author SeanDragon
| 16 | * @author SeanDragon |
| 17 | */ |
| 18 | public final class ToolOS { |
| 19 | public static final String JAVA_VERSION = getOsSystemProperty("java.version"); // Java的运行环境版本 |
| 20 | public static final String JAVA_VENDO = getOsSystemProperty("java.vendor"); // Java的运行环境供应商 |
| 21 | public static final String JAVA_VENDO_URL = getOsSystemProperty("java.vendor.url"); // Java供应商的URL |
| 22 | public static final String JAVA_HOME = getOsSystemProperty("java.home"); // Java的安装路径 |
| 23 | public static final String JAVA_VM_SPECIFICATION_VERSION = getOsSystemProperty("java.vm.specification.version"); // Java的虚拟机规范版本 |
| 24 | public static final String JAVA_VM_SPECIFICATION_VENDOR = getOsSystemProperty("java.vm.specification.vendor"); // Java的虚拟机规范供应商 |
| 25 | public static final String JAVA_VM_SPECIFICATION_NAME = getOsSystemProperty("java.vm.specification.name"); // Java的虚拟机规范名称 |
| 26 | public static final String JAVA_VM_VERSION = getOsSystemProperty("java.vm.version"); // Java的虚拟机实现版本 |
| 27 | public static final String JAVA_VM_VENDOR = getOsSystemProperty("java.vm.vendor"); // Java的虚拟机实现供应商 |
| 28 | public static final String JAVA_VM_NAME = getOsSystemProperty("java.vm.name"); // Java的虚拟机实现名称 |
| 29 | public static final String JAVA_SPECIFICATION_VERSION = getOsSystemProperty("java.specification.version"); // Java运行时环境规范版本 |
| 30 | public static final String JAVA_SPECIFICATION_VENDER = getOsSystemProperty("java.specification.vender"); // Java运行时环境规范供应商 |
| 31 | public static final String JAVA_SPECIFICATION_NAME = getOsSystemProperty("java.specification.name"); // Java运行时环境规范名称 |
| 32 | public static final String JAVA_CLASS_VERSION = getOsSystemProperty("java.class.version"); // Java的类格式版本号 |
| 33 | public static final String JAVA_CLASS_PATH = getOsSystemProperty("java.class.path"); // Java的类路径 |
| 34 | public static final String JAVA_LIBRARY_PATH = getOsSystemProperty("java.library.path"); // 加载库时搜索的路径列表 |
| 35 | public static final String JAVA_IO_TMPDIR = getOsSystemProperty("java.io.tmpdir"); // 默认的临时文件路径 |
| 36 | public static final String JAVA_EXT_DIRS = getOsSystemProperty("java.ext.dirs"); // 一个或多个扩展目录的路径 |
| 37 | public static final String OS_NAME = getOsSystemProperty("os.name"); // 操作系统的名称 |
| 38 | public static final String OS_ARCH = getOsSystemProperty("os.arch"); // 操作系统的构架 |
| 39 | public static final String OS_VERSION = getOsSystemProperty("os.version"); // 操作系统的版本 |
| 40 | public static final String FILE_SEPARATOR = getOsSystemProperty("java.file.separator"); // 文件分隔符 |
| 41 | public static final String PATH_SEPARATOR = getOsSystemProperty("path.separator"); // 路径分隔符 |
| 42 | public static final String LINE_SEPARATOR = getOsSystemProperty("line.separator"); // 行分隔符 |
| 43 | public static final String USER_NAME = getOsSystemProperty("user.name"); // 用户的账户名称 |
| 44 | public static final String USER_HOME = getOsSystemProperty("user.home"); // 用户的主目录 |
| 45 | public static final String USER_DIR = getOsSystemProperty("user.dir"); // 用户的当前工作目录 |
| 46 | /** |
| 47 | * 系统Bean |
| 48 | */ |
| 49 | private static final OperatingSystemMXBean SYSTEM_MX_BEAN; |
| 50 | private static final List<GarbageCollectorMXBean> LIST; |
| 51 | /** |
| 52 | * K转换M |
| 53 | */ |
| 54 | private static final long K2M = 1024L * 1024L; |
| 55 | |
| 56 | static { |
| 57 | SYSTEM_MX_BEAN = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); |
| 58 | LIST = ManagementFactory.getGarbageCollectorMXBeans(); |
| 59 | } |
| 60 | |
| 61 | private ToolOS() { |
| 62 | throw new UnsupportedOperationException("我是工具类,别初始化我。。。"); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * 获取java系统环境变量 |
| 67 | * |
| 68 | * @param key |
| 69 | * |
| 70 | * @return |
| 71 | */ |
| 72 | public static String getOsSystemProperty(String key) { |
| 73 | return System.getProperty(key); |
| 74 | } |
| 75 |
nothing calls this directly
no test coverage detected