简体   繁体   中英

Java Properties.load() - how to switch key value pairs?

I need to read in a Properties object from a file, however I need to switch the key and value pairs around, ie I need the keys to become the property values and vice-versa. I also cannot just change this on the file I am reading in. Any ideas how I could do this?

Thanks

您可以创建第二个Properties对象,遍历刚刚读过的entires,调用put(entry.getValue(), entry.getKey())然后就可以了。

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