public static RestxConfig parse(String origin, InputSupplier<InputStreamReader> readerSupplier) throws IOException { List<ConfigElement> elements = new ArrayList<>(); StringBuilder doc = new StringBuilder(); int lineCount = 0; for (String line : CharStreams.readLines(readerSupplier)) { lineCount++; if (line.startsWith("#")) { doc.append(line.substring(1).trim()).append("\n"); } else if (!line.trim().isEmpty()) { int index = line.indexOf('='); if (index == -1) { throw new IOException( "invalid config " + origin + " at line " + lineCount + ":" + " line does not contain the equals sign '='"); } String key = line.substring(0, index).trim(); String value = line.substring(index + 1).trim(); elements.add(ConfigElement.of(origin, doc.toString().trim(), key, value)); doc.setLength(0); } } return new StdRestxConfig(elements); }