从配置文件读取信息

类别:Java 点击:0 评论:0 推荐:

  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();
      }

  }

本文地址:http://com.8s8s.com/it/it13452.htm