public List<PublicSuffixList> parseByType(final Reader reader) throws IOException {
        final List<PublicSuffixList> result = new ArrayList<>(2);

        final BufferedReader r = new BufferedReader(reader);

        DomainType domainType = null;
        List<String> rules = null;
        List<String> exceptions = null;
        String line;
        while ((line = r.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            if (line.startsWith("//")) {

                if (domainType == null) {
                    if (line.contains("===BEGIN ICANN DOMAINS===")) {
                        domainType = DomainType.ICANN;
                    } else if (line.contains("===BEGIN PRIVATE DOMAINS===")) {
                        domainType = DomainType.PRIVATE;
                    }
                } else {
                    if (line.contains("===END ICANN DOMAINS===") || line.contains("===END PRIVATE DOMAINS===")) {
                        if (rules != null) {
                            result.add(new PublicSuffixList(domainType, rules, exceptions));
                        }
                        domainType = null;
                        rules = null;
                        exceptions = null;
                    }
                }

                continue; //entire lines can also be commented using //
            }
            if (domainType == null) {
                continue;
            }

            if (line.startsWith(".")) {
                line = line.substring(1); // A leading dot is optional
            }
            // An exclamation mark (!) at the start of a rule marks an exception to a previous wildcard rule
            final boolean isException = line.startsWith("!");
            if (isException) {
                line = line.substring(1);
            }

            if (isException) {
                if (exceptions == null) {
                    exceptions = new ArrayList<>();
                }
                exceptions.add(line);
            } else {
                if (rules == null) {
                    rules = new ArrayList<>();
                }
                rules.add(line);
            }
        }
        return result;
    }
Parses the public suffix list format by domain type (currently supported ICANN and PRIVATE).
<p>
When creating the reader from the file, make sure to use the correct encoding
(the original list is in UTF-8).

@param reader the data reader. The caller is responsible for closing the reader.
@throws IOException on error while reading from list

@since 4.5
ngrinder-runtime/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixListParser.java