java常用工具类

读取property

 private static Properties pro=new Properties();
    static {
        InputStream in = App.class.getClassLoader().getResourceAsStream("jdbc.properties");
        try  {
            pro.load(in);
        }catch (IOException e){
            e.printStackTrace();
        }

    }
    public static void main( String[] args ){

        System.out.println(getProperty("username"));
    }
    public  static  String getProperty(String key){
        return pro.getProperty(key);

    }

  

posted @ 2020-03-10 14:27  魏晋南北朝  阅读(143)  评论(0编辑  收藏  举报