I need to use UTF-8 in my resource properties using Java\'s ResourceBundle
. When I enter the text directly into the properties file, it displays as mojibake.
look at this : http://docs.oracle.com/javase/6/docs/api/java/util/Properties.html#load(java.io.Reader)
the properties accept an Reader object as arguments, which you can create from an InputStream.
at the create time, you can specify the encoding of the Reader:
InputStreamReader isr = new InputStreamReader(stream, "UTF-8");
then apply this Reader to the load method :
prop.load(isr);
BTW: get the stream from .properties file :
InputStream stream = this.class.getClassLoader().getResourceAsStream("a.properties");
BTW: get resource bundle from InputStreamReader
:
ResourceBundle rb = new PropertyResourceBundle(isr);
hope this can help you !