JavaPropertiesResource extends ResourceFilter { @Override public LanguageBundle parse(InputStream inStream, FilterOptions options) throws IOException, ResourceFilterException { LinkedProperties props = new LinkedProperties(); BufferedReader inStreamReader = new BufferedReader(new InputStreamReader(inStream, getCharset())); String line; Map<String, List<String>> notesMap = new HashMap<>(); List<String> currentNotes = new ArrayList<>(); boolean globalNotesAvailable = true; List<String> globalNotes = null; while ((line = inStreamReader.readLine()) != null) { line = stripLeadingSpaces(line); if (line.startsWith("#") || line.startsWith("!")) { if (enc == Encoding.UTF_8) { currentNotes.add(line.substring(1)); } else { currentNotes.add(unescapeOnlyUnicode(line.substring(1))); } } else if (line.isEmpty()) { if (globalNotesAvailable && !currentNotes.isEmpty()) { globalNotes = new ArrayList<>(currentNotes); currentNotes.clear(); } else { currentNotes.add(line); } globalNotesAvailable = false; } else { StringBuffer sb = new StringBuffer(line); while (isContinuationLine(sb.toString())) { String continuationLine = inStreamReader.readLine(); sb.setLength(sb.length() - 1); if (continuationLine != null) { sb.append(stripLeadingSpaces(continuationLine)); } } String logicalLine = sb.toString(); PropDef pd = PropDef.parseLine(logicalLine); String value = unescapeMessagePattern(pd.getValue(), msgPatEsc); props.setProperty(pd.getKey(), value); if (!currentNotes.isEmpty()) { notesMap.put(pd.getKey(), new ArrayList<>(currentNotes)); currentNotes.clear(); } } } Iterator<Object> i = props.orderedKeys().iterator(); LanguageBundleBuilder bb = new LanguageBundleBuilder(true); while (i.hasNext()) { String key = (String) i.next(); List<String> notes = notesMap.get(key); bb.addResourceString(ResourceString.with(key, props.getProperty(key)).notes(notes)); } if (globalNotes != null) { bb.addNotes(globalNotes); } return bb.build(); } JavaPropertiesResource(Encoding enc, MessagePatternEscape msgPatEsc);  JavaPropertiesResource(); @Override LanguageBundle parse(InputStream inStream, FilterOptions options); @Override void write(OutputStream outStream, LanguageBundle languageBundle,
            FilterOptions options); @Override void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
            FilterOptions options);  }
@Test public void testParse() throws IOException, ResourceFilterException { assertTrue("The input test file <" + INPUT_FILE + "> does not exist.", INPUT_FILE.exists()); try (InputStream is = new FileInputStream(INPUT_FILE)) { LanguageBundle bundle = res.parse(is, null); List<ResourceString> resStrList = new ArrayList<>(bundle.getResourceStrings()); Collections.sort(resStrList, new ResourceStringComparator()); assertEquals("ResourceStrings did not match.", EXPECTED_INPUT_RES_LIST, resStrList); } }