I have a problem getting localized value (a UTF-8 string) from the properties file.
Here is what i did ..
//properties file containing
//name=हिन्दी
public static void main(String[] args)
{
File f = new File("path\\to\\properties\\file");
Properties p = new Properties();
try
{
p.load(new InputStreamReader(new FileInputStream(f),Charset.forName("UTF-8")));
}
catch(IOException iox) {}
System.out.println(p.getProperty("name")); //outputs null
System.out.println(p.toString()); //outputs { name= हिन्दी }
}
Thanks
If the last line actually outputs name= हिन्दी then it looks like there's something wrong with the key String in the properties file; perhaps in includes some invisible whitespace character or one of the charaters of "name" is not the regular latin letter but something that looks like it. Take a look at the properties file in a hex editor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With