YMLResource extends ResourceFilter { @SuppressWarnings("unchecked") @Override public void write(OutputStream outStream, LanguageBundle languageBundle, FilterOptions options) throws IOException, ResourceFilterException { List<ResourceString> resStrings = languageBundle.getSortedResourceStrings(); char separator = '.'; HashMap<String, Object> temp_map = new HashMap<String, Object>(); HashMap<String, Object> new_map = temp_map; for (ResourceString res : resStrings) { String value = res.getValue(); String key = res.getKey(); String[] temp = key.split("\\" + separator); for (int i = 0; i < temp.length; i++) { if (i == temp.length - 1) { temp_map.put(temp[i], value); } else { if (!temp_map.containsKey(temp[i])) { temp_map.put(temp[i], new HashMap<String, Object>()); } temp_map = (HashMap<String, Object>) temp_map.get(temp[i]); } } temp_map = new_map; } writeFile(outStream, temp_map, 0); }  @Override LanguageBundle parse(InputStream inStream, FilterOptions options); @SuppressWarnings("unchecked") @Override void write(OutputStream outStream, LanguageBundle languageBundle,
            FilterOptions options);  }
@Test public void testWrite() throws IOException, ResourceFilterException { File tempFile = File.createTempFile(this.getClass().getSimpleName(), ".yml"); tempFile.deleteOnExit(); try (OutputStream os = new FileOutputStream(tempFile)) { res.write(os, WRITE_BUNDLE, null); os.flush(); } }