CpuInfo { public static Optional<ProcDetails> getProcDetails() { List<Map<String, String>> cpuinfo = new ArrayList<>(); try { String data = Files.readString(Path.of("/proc/cpuinfo"), StandardCharsets.UTF_8); String[] sections = data.split("\n\n"); for (String section : sections) { Map<String, String> cpuMap = new HashMap<>(); cpuinfo.add(cpuMap); String[] props = section.split("\n"); for (String prop : props) { String[] assignment = prop.split("\\s*:\\s*"); if (assignment.length == 2) { String property = assignment[0].trim(); String value = assignment[1].trim(); cpuMap.put(property, value); } else { cpuMap.put(assignment[0], ""); } } } } catch (Exception e) { logger.warn("Unable to learn about CPU architecture: " + e.getMessage()); return Optional.empty(); } return Optional.of(new ProcDetails(cpuinfo)); }  static Optional<ProcDetails> getProcDetails();  }
@Test public void testProcScanner() { Optional<CpuInfo.ProcDetails> procDetails = CpuInfo.getProcDetails(); assertThat(procDetails).isPresent(); System.out.println(procDetails.get()); }