@Test public void testUTF8() throws IOException { File properties = new File("target/test-classes/utf-8.properties"); FileInputStream fis = null; try { fis = new FileInputStream(properties); UTF8PropertiesResourceBundle bundle = new UTF8PropertiesResourceBundle(fis); String japanese = (String) bundle.handleGetObject("japanese"); String russian = (String) bundle.handleGetObject("russian"); String polish = (String) bundle.handleGetObject("polish"); String german = (String) bundle.handleGetObject("german"); String unit = (String) bundle.handleGetObject("unit"); assertThat(japanese).isEqualTo("てすと"); assertThat(russian).isEqualTo("Я Б Г Д Ж Й"); assertThat(polish).isEqualTo("Ł Ą Ż Ę Ć Ń Ś Ź"); assertThat(german).isEqualTo("Ä ä Ü ü ß"); assertThat(unit).isEqualTo("℃ å"); assertThat(bundle.handleGetObject("do_not_exist")).isNull(); } finally { IOUtils.closeQuietly(fis); } }
protected Object handleGetObject(String key) { String value = (String) bundle.handleGetObject(key); if (value == null) { return null; } else { return new String(value.getBytes(Charsets.ISO_8859_1), Charsets.UTF_8); } }
UTF8PropertiesResourceBundle extends ResourceBundle { protected Object handleGetObject(String key) { String value = (String) bundle.handleGetObject(key); if (value == null) { return null; } else { return new String(value.getBytes(Charsets.ISO_8859_1), Charsets.UTF_8); } } }
UTF8PropertiesResourceBundle extends ResourceBundle { protected Object handleGetObject(String key) { String value = (String) bundle.handleGetObject(key); if (value == null) { return null; } else { return new String(value.getBytes(Charsets.ISO_8859_1), Charsets.UTF_8); } } UTF8PropertiesResourceBundle(InputStream is); }
UTF8PropertiesResourceBundle extends ResourceBundle { protected Object handleGetObject(String key) { String value = (String) bundle.handleGetObject(key); if (value == null) { return null; } else { return new String(value.getBytes(Charsets.ISO_8859_1), Charsets.UTF_8); } } UTF8PropertiesResourceBundle(InputStream is); Enumeration<String> getKeys(); }
UTF8PropertiesResourceBundle extends ResourceBundle { protected Object handleGetObject(String key) { String value = (String) bundle.handleGetObject(key); if (value == null) { return null; } else { return new String(value.getBytes(Charsets.ISO_8859_1), Charsets.UTF_8); } } UTF8PropertiesResourceBundle(InputStream is); Enumeration<String> getKeys();  }