Read a file and return a map of string keys to string values contained therein. Intended primarily for Linux /proc/[pid] files to provide more detailed or accurate information not available in the API. @param filename The file to read @param separator Character(s) in e
(String filename, String separator)
| 253 | * map is returned. |
| 254 | */ |
| 255 | public static Map<String, String> getKeyValueMapFromFile(String filename, String separator) { |
| 256 | Map<String, String> map = new HashMap<>(); |
| 257 | if (LOG.isDebugEnabled()) { |
| 258 | LOG.debug(READING_LOG, filename); |
| 259 | } |
| 260 | List<String> lines = FileUtil.readFile(filename, false); |
| 261 | for (String line : lines) { |
| 262 | String[] parts = line.split(separator); |
| 263 | if (parts.length == 2) { |
| 264 | map.put(parts[0], parts[1].trim()); |
| 265 | } |
| 266 | } |
| 267 | return map; |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * Read a configuration file from the sequence of context classloader, system |