FileUtil { public static Map<String, String> getKeyValueMapFromFile(String filename, String separator) { Map<String, String> map = new HashMap<>(); if (LOG.isDebugEnabled()) { LOG.debug(READING_LOG, filename); } List<String> lines = FileUtil.readFile(filename, false); for (String line : lines) { String[] parts = line.split(separator); if (parts.length == 2) { map.put(parts[0], parts[1].trim()); } } return map; } private  FileUtil(); static List<String> readFile(String filename); static List<String> readFile(String filename, boolean reportError); static long getLongFromFile(String filename); static long getUnsignedLongFromFile(String filename); static int getIntFromFile(String filename); static String getStringFromFile(String filename); static Map<String, String> getKeyValueMapFromFile(String filename, String separator); static Properties readPropertiesFromFilename(String propsFilename);  }
@Test public void testReadProcIo() { Map<String, String> expected = new HashMap<>(); expected.put("rchar", "124788352"); expected.put("wchar", "124802481"); expected.put("syscr", "135"); expected.put("syscw", "1547"); expected.put("read_bytes", "40304640"); expected.put("write_bytes", "124780544"); expected.put("cancelled_write_bytes", "42"); Map<String, String> actual = FileUtil.getKeyValueMapFromFile(PROCIO_FILE, ":"); assertEquals(expected.size(), actual.size()); for (String key : expected.keySet()) { assertEquals(expected.get(key), actual.get(key)); } }