使用java.util.ResourceBundle就可以了。

解决方案 »

  1.   

    public ConfigPath{
      java.util.ResourceBundle rb = null;
      public ConfigPath(String propFilePath){
        if(propFilePath!=null && propFilePath.trim().length()>0)
          rb = java.util.ResourceBundle.getBundle(propFilePath.trim());
        else
          System.out.println("[ConfigPath]Property file's path is invalid.");
      }  public String getProperty(String key){
        if(key!=null && key.trim().length()>0)
          return resB.getString(key.trim());
        System.out.println("[ConfigPath.getProperty]The key's value is invalid.");
      }}
      

  2.   

    public void init(String fileName) throws ConfigReaderException {        FileInputStream fis = null;        try {
                fis = new FileInputStream(fileName);
                props.load(fis);        } catch (FileNotFoundException fe) {
            } catch (IOException ie) {
            } finally {
                try {
                    if (fis != null) {
                        fis.close();
                    }
                    fis = null;
                } catch (IOException ie) {
                }
            }    }