你还记读取properties文件的方法吗

首先properties文件的格式是这样的

xxx=xxx  (不要加引号)

然后上代码

   public String ReadPorps(String key)throws Exception{
        //Dome.class.getClassLoader()获取文件路径类加载器
        InputStreamReader in = new InputStreamReader(ReadExcelUtil.class.getClassLoader().getResourceAsStream("这里放你的文件路径"),"GBK");
        //读取文件
         String orgid = null;
         try {
           Properties properties=new Properties();
           properties.load(in);
            orgid = properties.getProperty(key);
             System.out.println(orgid);
           return orgid;
       }catch (Exception e){
           e.printStackTrace();
       }
   return  orgid;
       }
 

猜你喜欢

转载自blog.csdn.net/wangzhichaogege/article/details/108217395