Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading properties file with UTF-8 encoding  RSS feed

 
abhi narkar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to read a properties file that may contain characters from other languages like Japanese/Russian etc.. as values, so my properties file is in UTF-8 encoding. When I read it using Properties.load(InputStream) method it reads with default encoding that causes distortion of any Japanese/Russian characters, which cause further problem ahead. Any solution so that my Properties object will be populated correctly i.e. with UTF-8 encoding?
Thanks,
~Abhi
 
Ulf Dittmer
Rancher
Posts: 42970
73
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you could use the Properties.load(Reader) method, passing it a Reader which uses UTF-8 as its charset.
 
Tony Docherty
Bartender
Posts: 3201
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you could use the nativetoascii tool that ships with java to convert the properties files. It handles any character encoding known to Java and tool changes all non ascii characters to unicode escape sequences.
 
abhi narkar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all, using Properties.load(Reader) works fine.
 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abhi narkar wrote:Thanks all, using Properties.load(Reader) works fine.


Hello,

Can you please share your code to benefit this community?

Thanks in anticipation
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!