开发者

Saving parameters in a file

开发者 https://www.devze.com 2023-04-01 12:42 出处:网络
I want to use a .properties file to store some parameters with values. I also want to use these parameters as class attributes in my code. How to avoid a situation where I need to define the attribute

I want to use a .properties file to store some parameters with values. I also want to use these parameters as class attributes in my code. How to avoid a situation where I need to define the attributes and use their开发者_如何学C names as string keys for the .properties file. I have these names twice in my code: once as an attribute and once as a string.

Reflection would help, but there is no reflection for attribute names.


there is no reflection for attribute names

If by "attributes" you mean "fields", then this is untrue: Class.getDeclaredFields() returns those. If you mean something else, please explain what you mean.

0

精彩评论

暂无评论...
验证码 换一张
取 消