简体   繁体   中英

How to use Hungarian characters as a key in properties file with ResourceBundle in JAVA?

I have a properties file where i got letters as keys and some integer value. Something like this:

a=1
b=2
c=5
...

Everything works but when I use Hungarian letters as keys (for example: "ő" or "ű") I got the following exception: "Can't find resource for bundle java.util.PropertyResourceBundle, key ő." I want something like that:

ő=7

I guess my properties file's encoding isn't UTF-8 but how can I change it?

Have you tried to use \ő=7 instead of ő=7 in the .properties file? (For other characters please see http://www.utf8-chartable.de/unicode-utf8-table.pl?start=256&unicodeinhtml=hex or some other encoding table).

And to answer your encoding question - please try to use Notepad++. You can save/convert various char encodings with it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM