Make Java Properties available across classes?

前端 未结 8 2229
情深已故
情深已故 2020-12-30 08:16

I chose to take properties file for customization of some settings. I use the following code to make a Properties Object available in a class

Properties defa         


        
相关标签:
8条回答
  • 2020-12-30 08:49

    Why not use a static ResourceBundle ?

    static final ResourceBundle myResources = 
              ResourceBundle.getBundle("MyResources", currentLocale);
    
    0 讨论(0)
  • 2020-12-30 08:53

    There's too little information to determine what the best way to handle this would be. You may want to expose it using an accessor, or pass it into each class that requires it. Alternatively, you may pull out the properties that each class needs and pass their values into the class's constructor.

    0 讨论(0)
提交回复
热议问题