AmdJsResource extends ResourceFilter { @Override public void write(OutputStream outStream, LanguageBundle languageBundle, FilterOptions options) throws IOException, ResourceFilterException { try (OutputStreamWriter writer = new OutputStreamWriter(new BufferedOutputStream(outStream), StandardCharsets.UTF_8)) { writer.write("define({\n"); boolean first = true; final Character quote = '"'; for (ResourceString res : languageBundle.getSortedResourceStrings()) { if (first) { first = false; } else { writer.write(",\n"); } writer.write(quote + escapeString(res.getKey(), quote) + quote + ": "); writer.write(quote + escapeString(res.getValue(), quote) + quote); } writer.write("\n});\n"); } }  @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 testWrite() throws IOException, ResourceFilterException { File tempFile = File.createTempFile(this.getClass().getSimpleName(), ".js"); tempFile.deleteOnExit(); try (OutputStream os = new FileOutputStream(tempFile)) { res.write(os, WRITE_BUNDLE, null); os.flush(); assertTrue(ResourceTestUtil.compareFiles(EXPECTED_WRITE_FILE, tempFile)); } }