1

I want to read hindi text from lang.properties(JAVA.util.properties) file. I am using eclipse IDE.

First of all how can I save(or write) hindi letter in .properties file

Secondly how to read the string from my java class.

lang.properties

hindiText=साहिलसाहिल

Java Class

Properties prop = new Properties();
prop.load(MyCalss.class.getClassLoader().getResourceAsStream("lang.properties"));
String hindi=prop.getProperty("hindiText");

It's not working.

3
  • Where is your lang.properties stored? Jul 17, 2013 at 13:56
  • Read Java Internationization tutorial docs.oracle.com/javase/tutorial/i18n
    – AurA
    Jul 17, 2013 at 13:57
  • 1
    In future, please understand that "its not working" is not an adequate description of your problem. It's the software equivalent of asking a doctor to diagnose your illness on the basis of "I don't feel well". Please read tinyurl.com/so-hints
    – Jon Skeet
    Jul 17, 2013 at 13:57

1 Answer 1

4

As documented, Properties.load(InputStream) will always use the ISO-8859-1 encoding, and that encoding doesn't handle the characters you're interested in.

Options:

  • Wrap your stream in an InputStreamReader and specify the encoding explicitly
  • Use Unicode escaping (e.g \u1234) in the file for any characters not in ISO-8859-1 (and make sure the file is saved as ISO-8859-1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.