Class SystemUtil

java.lang.Object
com.sure.tool.util.SystemUtil

public class SystemUtil extends Object
系统属性工具类,参考 Hutool 的 SystemUtil 设计。

English: Runtime and operating-system information helpers.

Since:
0.1.0
Author:
suretool
  • Method Details

    • get

      public static String get(String key)
      获取系统属性。
      Parameters:
      key - 属性名,如 "os.name"
      Returns:
      属性值,不存在返回 null
    • get

      public static String get(String key, String defaultValue)
      获取系统属性,不存在返回默认值。
      Parameters:
      key - 属性名
      defaultValue - 默认值
      Returns:
      属性值
    • getOsName

      public static String getOsName()
      操作系统名称,如 "Windows 11"。
      Returns:
      操作系统名称
    • getOsArch

      public static String getOsArch()
      操作系统架构,如 "amd64"。
      Returns:
      操作系统架构
    • getOsVersion

      public static String getOsVersion()
      操作系统版本。
      Returns:
      操作系统版本
    • getJavaVersion

      public static String getJavaVersion()
      Java 版本,如 "17.0.3"。
      Returns:
      Java 版本
    • getJavaHome

      public static String getJavaHome()
      Java 安装目录。
      Returns:
      Java 安装目录
    • getUserName

      public static String getUserName()
      当前用户名。
      Returns:
      当前用户名
    • getUserDir

      public static String getUserDir()
      当前工作目录。
      Returns:
      当前工作目录
    • getUserHome

      public static String getUserHome()
      用户主目录。
      Returns:
      用户主目录
    • getLineSeparator

      public static String getLineSeparator()
      行分隔符。
      Returns:
      行分隔符
    • getFileSeparator

      public static String getFileSeparator()
      文件分隔符(Windows 为 \,Linux 为 /)。
      Returns:
      文件分隔符
    • getPathSeparator

      public static String getPathSeparator()
      路径分隔符。
      Returns:
      路径分隔符
    • getTotalMemory

      public static long getTotalMemory()
      JVM 总内存(字节)。
      Returns:
      总内存
    • getFreeMemory

      public static long getFreeMemory()
      JVM 空闲内存(字节)。
      Returns:
      空闲内存
    • getMaxMemory

      public static long getMaxMemory()
      JVM 最大可用内存(字节)。
      Returns:
      最大可用内存
    • getTotalThreadCount

      public static int getTotalThreadCount()
      获取当前 JVM 活动线程数。
      Returns:
      线程数