当前工程目录读取配置示例:

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println(getConfigPath());

    }
    public static String getConfigDir(){
        String userDir=System.getProperty("user.dir");
        if(System.getProperty("os.name").toLowerCase().contains("windows")){
            return userDir+File.separator+"conf";
        }else{
            return userDir+File.separator+"conf";
        }
    }
    public static String getConfigPath(){
        return getConfigDir()+File.separator+"config.properties";
    }

 

posted on 2015-02-06 19:33  一天不进步,就是退步  阅读(264)  评论(0编辑  收藏  举报