public static Ini parse(InputStream input) {
        SortedMap<String, SortedMap<String, String>> entries = new TreeMap<>();
        Scanner scanner = new Scanner(input, StandardCharsets.UTF_8);
        String section = "";
        int lineNum = 0;
        while (scanner.hasNextLine()) {
            lineNum++;
            String line = scanner.nextLine().trim();
            // Blank line
            if (line.isEmpty()) {
                continue;
            }
            // Comment
            if (isComment(line)) {
                continue;
            }
            // Section
            if (line.startsWith("[") && line.endsWith("]")) {
                section = line.substring(1, line.length() - 1);
                continue;
            }
            // Key-value entry
            try {
                Entry entry = Entry.parse(line);
                entries.putIfAbsent(section, new TreeMap<>());
                String prevValue = entries.computeIfAbsent(section, (k) -> new TreeMap<>())
                                          .put(entry.key, entry.value);
                if (prevValue != null) {
                    throw new IllegalArgumentException("Key '" + entry.key + "' duplicated in section '" +
                                                       section + "'");
                }
            } catch (IllegalArgumentException e) {
                throw new IllegalArgumentException("Invalid entry on line " + lineNum + ": '" + line + "': " +
                                                   Exceptions.toMessageString(e));
            }
        }
        return new Ini(entries);
    }
Parse an INI configuration from given input
vespajlib/src/main/java/com/yahoo/config/ini/Ini.java