Source:
<code>public void load(InputStream passwordsStream, InputStream groupsStream) throws IOException { Map<String, AccountEntry> accounts = new HashMap<>(); Properties groups = new Properties(); if (groupsStream != null) { try (InputStreamReader is = new InputStreamReader(groupsStream, StandardCharsets.UTF_8);) { groups.load(is); } } String realmName = null; try (BufferedReader reader = new BufferedReader(new InputStreamReader(passwordsStream, StandardCharsets.UTF_8))) { String currentLine; while ((currentLine = reader.readLine()) != null) { final String trimmed = currentLine.trim(); if (trimmed.startsWith(COMMENT_PREFIX) && trimmed.contains(REALM_COMMENT_PREFIX)) { int start = trimmed.indexOf(REALM_COMMENT_PREFIX) + REALM_COMMENT_PREFIX.length(); int end = trimmed.indexOf(REALM_COMMENT_SUFFIX, start); if (end > -1) { realmName = trimmed.substring(start, end); } } else { if ( ! trimmed.startsWith(COMMENT_PREFIX)) { String username = null, password; StringBuilder builder = new StringBuilder(); int i = 0; while (i < trimmed.length()) { <START> char ch = trimmed.charAt(i); <END> if (ch == '\\' && i+1 < trimmed.length()) { builder.append(trimmed.charAt(i+1)); i += 2; continue; } if (username == null && (ch == '=' || ch == ':')) { username = builder.toString().trim(); builder = new StringBuilder(); i++; continue; } builder.append(ch); i++; } if (username != null) { password = builder.toString().trim(); accounts.put(username, new AccountEntry(username, password, groups.getProperty(username))); } } } } } if (realmName == null) { throw log.noRealmFoundInProperties(); } loadedState.set(new LoadedState(accounts, realmName, System.currentTimeMillis())); }</code><technical_language>codePointAt()... a CodePointIterator</technical_language>

Target:
public void load(InputStream passwordsStream, InputStream groupsStream) throws IOException { Map<String, AccountEntry> accounts = new HashMap<>(); Properties groups = new Properties(); if (groupsStream != null) { try (InputStreamReader is = new InputStreamReader(groupsStream, StandardCharsets.UTF_8);) { groups.load(is); } } String realmName = null; try (BufferedReader reader = new BufferedReader(new InputStreamReader(passwordsStream, StandardCharsets.UTF_8))) { String currentLine; while ((currentLine = reader.readLine()) != null) { final String trimmed = currentLine.trim(); if (trimmed.startsWith(COMMENT_PREFIX1) && trimmed.contains(REALM_COMMENT_PREFIX)) { int start = trimmed.indexOf(REALM_COMMENT_PREFIX) + REALM_COMMENT_PREFIX.length(); int end = trimmed.indexOf(REALM_COMMENT_SUFFIX, start); if (end > -1) { realmName = trimmed.substring(start, end); } } else { if ( ! (trimmed.startsWith(COMMENT_PREFIX1) || trimmed.startsWith(COMMENT_PREFIX2)) ) { String username = null; StringBuilder builder = new StringBuilder(); CodePointIterator it = CodePointIterator.ofString(trimmed); while (it.hasNext()) { int cp = it.next(); if (cp == '\\' && it.hasNext()) { builder.appendCodePoint(it.next()); } else if (username == null && (cp == '=' || cp == ':')) { username = builder.toString().trim(); builder = new StringBuilder(); } else { builder.appendCodePoint(cp); } } if (username != null) { String password = builder.toString().trim(); accounts.put(username, new AccountEntry(username, password, groups.getProperty(username))); } } } } } if (realmName == null) { throw log.noRealmFoundInProperties(); } loadedState.set(new LoadedState(accounts, realmName, System.currentTimeMillis())); }