如何自动连接多个属性文件:

时间:2019-05-08 10:41:23

标签: spring-mvc

我需要替换文件I / O。我想在Java调用中自动装配多个属性文件。目前,我正在阅读使用文件I / O的内容。我必须删除文件读取

class MyConfig{

    private static Properties configProperties = new Properties();
    private static Properties genderProperties = new Properties();
    private static Properties esbUrlProperties= new Properties();

    static
    { 
        try
        {
            configProperties.load(new FileInputStream("config.properties"));
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        try
        {
            genderProperties.load(new FileInputStream("master.gender.properties"));
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        try{
            esbUrlProperties.load(new FileInputStream("esbUrl.properties"));
        }catch(Exception e){
            e.printStackTrace();
        }

        try{
           messageProperties.load(new FileInputStream("message.properties")); 
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}

0 个答案:

没有答案