class JavaPropertiesResource extends ResourceFilter {

    @Override
    public void write(OutputStream outStream, LanguageBundle languageBundle,
            FilterOptions options) throws IOException, ResourceFilterException {

        List<ResourceString> resStrings = languageBundle.getSortedResourceStrings();
        BreakIterator brkItr = Utils.getWordBreakIterator(options);

        PrintWriter pw = new PrintWriter(new OutputStreamWriter(outStream, getCharset()));
        for (String note : languageBundle.getNotes()) {
            if (enc == Encoding.UTF_8) {
                // No needs to escape raw Unicode charters
                pw.println("#" + note);
            } else {
                // Needs to escape Unicode characters
                pw.println("#" + escapeOnlyUnicode(note));
            }
        }
        if (!languageBundle.getNotes().isEmpty()) {
            pw.println();
        }
        pw.println("#"+new Date().toString());
        for (ResourceString res : resStrings) {
            String value = res.getValue();  
            value = escapeMessagePattern(value, msgPatEsc);
            PropDef pd = new PropDef(res.getKey(),value,PropDef.PropSeparator.EQUAL,res.getNotes());
            pd.print(pw, brkItr, (enc == Encoding.UTF_8));
        }
        pw.close();
    }

}

class JavaPropertiesResourceTest {

    private static final File INPUT_FILE;
    private static final File EXPECTED_WRITE_FILE;
    private static final File EXPECTED_WRITE_FILE_ALL;
    private static final File EXPECTED_MERGE_FILE;
    private static final File PARSE_TEST_INPUT_FILE;
    private static final Collection<ResourceString> EXPECTED_INPUT_RES_LIST;
    private static LanguageBundle WRITE_BUNDLE;
    private static LanguageBundle WRITE_BUNDLE_ALL;
    private static LinkedList<PropDef> EXPECTED_PROP_DEF_LIST;
    private static final JavaPropertiesResource res;
    private static final String[][] UNESC_TEST_CASES;
    private static final String[][] MESSAGE_PATTERN_TEST_CASES;

    @Test
    public void testWriteAllQuotes() throws IOException, ResourceFilterException {

        File tempFile = File.createTempFile(this.getClass().getSimpleName(), ".properties");
        JavaPropertiesResource res = new JavaPropertiesResource(Encoding.ISO_8859_1, MessagePatternEscape.ALL);
        tempFile.deleteOnExit();
        try (OutputStream os = new FileOutputStream(tempFile)) {
            res.write(os, WRITE_BUNDLE_ALL, null);
            os.flush();
            // Ignore first line in both the files (first line empty in expected, first line contains timestamp in actual) 
            assertTrue(ResourceTestUtil.compareFiles(EXPECTED_WRITE_FILE_ALL, tempFile, 1));
        }
    }

}