首页 > 学院 > 开发设计 > 正文

从配置文件读取信息

2019-11-17 06:33:25
字体:
来源:转载
供稿:网友

  PRivate void loadPerpro() {
    Properties props = new Properties();
      try {
       
        String sysPath = System.getProperty("user.dir");
        System.out.println("application path : " + sysPath);
        FileInputStream fis = new FileInputStream(new File(sysPath+"/datatoldapsyn.perproties"));
        props.load(fis);
        this.strConnectString=(String)props.getProperty("dbConnectString");
        this.strUser = (String)props.getProperty("dbUser");
        this.strPwd = (String)props.getProperty("dbPwd");
        this.ldapHost = (String)props.getProperty("ldapHost");
        this.ldapOrg = (String)props.getProperty("ldapOrg");
        this.ldapDN = (String)props.getProperty("ldapDN");
        this.ldapPWD = (String)props.getProperty("ldapPWD");
      }
      catch (FileNotFoundException ex) {
        ex.printStackTrace();
      }
      catch (IOException ex1) {
        ex1.printStackTrace();
      }

  }



发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表