View Javadoc
1   package edu.jiangxin.apktoolbox.utils;
2   
3   import org.apache.logging.log4j.LogManager;
4   import org.apache.logging.log4j.Logger;
5   
6   import java.util.List;
7   
8   public class SystemInfoUtils {
9       private static final Logger logger = LogManager.getLogger(SystemInfoUtils.class.getSimpleName());
10  
11      public static final List<String> SYSTEM_INFO_LIST = List.of("os.name", "os.arch", "os.version",
12              "java.version", "java.vendor", "java.vm.version", "java.vm.vendor", "java.vm.name",
13              "java.specification.version", "java.specification.vendor", "java.specification.name",
14              "java.class.version", "java.class.path", "java.library.path", "java.io.tmpdir",
15              "java.compiler", "java.ext.dirs", "user.name", "user.home", "user.dir", "file.encoding",
16              "sun.jnu.encoding", "sun.arch.data.model", "sun.desktop", "sun.cpu.endian",
17              "sun.io.unicode.encoding", "sun.cpu.isalist");
18  
19      private SystemInfoUtils() {
20      }
21  
22      public static void logSystemInfo() {
23          if (!logger.isInfoEnabled()) {
24              return;
25          }
26          StringBuilder sb = new StringBuilder();
27          for (String key : SYSTEM_INFO_LIST) {
28              sb.append(key).append(": ").append(System.getProperty(key)).append("\n");
29          }
30          logger.info(sb.toString());
31      }
32  }