JAVA-获取内存和系统类型

  protected long getMemory() {
        OperatingSystemMXBean osmxb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
        return osmxb.getTotalPhysicalMemorySize();
    }

  

protected String getOsType() {
        String osName = System.getProperty("os.name");
        if (osName.startsWith("Linux"))
            return "Linux";
        if (osName.startsWith("Windows"))
            return "Windows";
        if ((osName.contains("SunOS")) || (osName.contains("Solaris")))
            return "Solaris";
        if (osName.contains("Mac"))
            return "Mac";
        if (osName.contains("FreeBSD")) {
            return "FreeBSD";
        }
        return "Other";
    }

  



上一篇:ES6字符串包含方法


下一篇:django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 1.3.1