What is the simplest way to do settings files in Java?

前端 未结 8 1478
清歌不尽
清歌不尽 2021-01-03 05:47

Obviously enough, I want to avoid hardcoding paths and such into my application, and as a result, I\'d like to make a settings file that will store simple things like string

8条回答
  •  被撕碎了的回忆
    2021-01-03 06:19

    There are generally two different ways for this. One language specific and one general. The general way to store settings is in a properties file which can be read by the Properties class. Please see this.

    The language specific way of storing properties would be to have a properties file for each language and a default one for fallback purpose. You can read these by using the Resource class and providing a locale. Please see this.

提交回复
热议问题