As per the java.util.Properties
API document:
The load(Reader) / store(Writer, String) methods load and store properties from and to a character based stream in a simple line-oriented format specified below. The load(InputStream) / store(OutputStream, String) methods work the same way as the load(Reader)/store(Writer, String) pair, except the input/output stream is encoded in ISO 8859-1 character encoding. Characters that cannot be directly represented in this encoding can be written using Unicode escapes ; only a single u character is allowed in an escape sequence. The native2ascii tool can be used to convert property files to and from other character encodings.
(note that ISO 8859-1
is not the same as ASCII
as many are incorrectly talking about here).
So, to fix the particular problem without the need for native2ascii
, you should use Properties#load(Reader)
with an InputStreamReader(input, charset)
instead.
Properties properties = new Properties();
properties.load(new InputStreamReader(classLoader.getResourceAsStream("file.properties"), "UTF-8"));
Note that this method was introduced in Java 1.6 over 4 years ago. Ensure that you re using it as well.
I don t do Spring, so I can t go in detail about how to get Spring to work that way, but it would be obvious that you need to override/replace the Spring s resource bundle manager, if any.