1.获取系统的临时文件夹地址
System.getProperty("java.io.tmpdir")
打印结果
C:\Users\cenxi\AppData\Local\Temp\
2.获取java项目的根文件夹上一级文件夹地址
System.getProperty("user.dir")
打印结果
D:\xxxxx\xxx_java_linux
3.获取操纵系统标识
System.getProperty("os.name")
更多的就不一 一试了
SystemDTO dto = new SystemDTO(); dto.setSysTime(System.currentTimeMillis()); dto.setOsName(System.getProperty("os.name")); dto.setOsArch(System.getProperty("os.arch")); dto.setOsVersion(System.getProperty("os.version")); dto.setUserLanguage(System.getProperty("user.language")); dto.setUserDir(System.getProperty("user.dir")); dto.setTotalPhysical(osmx.getTotalPhysicalMemorySize()/1024/1024); dto.setFreePhysical(osmx.getFreePhysicalMemorySize()/1024/1024); dto.setMemoryRate(BigDecimal.valueOf((1-osmx.getFreePhysicalMemorySize()*1.0/osmx.getTotalPhysicalMemorySize())*100).setScale(2, RoundingMode.HALF_UP)); dto.setProcessors(osmx.getAvailableProcessors()); dto.setJvmName(System.getProperty("java.vm.name")); dto.setJavaVersion(System.getProperty("java.version")); dto.setJavaHome(System.getProperty("java.home")); dto.setJavaTotalMemory(Runtime.getRuntime().totalMemory()/1024/1024); dto.setJavaFreeMemory(Runtime.getRuntime().freeMemory()/1024/1024); dto.setJavaMaxMemory(Runtime.getRuntime().maxMemory()/1024/1024); dto.setUserName(System.getProperty("user.name")); dto.setSystemCpuLoad(BigDecimal.valueOf(osmx.getSystemCpuLoad()*100).setScale(2, RoundingMode.HALF_UP)); dto.setUserTimezone(System.getProperty("user.timezone"));
标签:1024,dto,System,获取,指令,osmx,java,getProperty From: https://www.cnblogs.com/c2g5201314/p/17335971.html