Properties p = new Properties();
p.load(new FileInputStream("*.properties"));String DriverName = (String) p.get("DriverName");
String UserName = (String) p.get("UserName");......

解决方案 »

  1.   

    看看ResourceBundel类

    它的子类PropertyResourceBundle类.
      

  2.   

    import java.io.*;
    import java.util.*;public class EnvPro
    {
    public static Properties getEnv(String filename)
    {
    Properties p = new Properties();
    try
    {
    InputStream is = new FileInputStream(filename);
    p.load(is);
    }catch(Exception e)
    {
    System.out.println(e.toString());
    }
    return p;
    }
    }
      

  3.   

    使用ResourceBundle就可以了
    try{
     ResourceBundle d=ResourceBundle.getBundle(filename); String s=d.getString(keyname);}
    catch....
      

  4.   

    谢谢各位大侠指点,我用两种方法都试了试,相比之下使用ResourceBundle方便的多,再次感谢!