public void init() {
    //建立到属性文件的流
    InputStream is = getClass().getResourceAsStream("./dbconfig.properties");
    Properties dbProps = new Properties();
    try {
    //通过流读取属性文件
      dbProps.load(is);
      is.close();//关闭流
    }
    catch (Exception e) {
      System.err.println("不能读取属性文件. " +
                         "请确保db.properties在CLASSPATH指定的路径中");
      return;
    }finally{
      is = null;
    }
  //其他对属性文件的操作
  }