The Properties class represents a persistent set of properties. The Properties can be saved to a stream or loaded from a stream. Each key and its corresponding value in the property list is a string. 
关于怎么用,应该经常去看JAVA-API

解决方案 »

  1.   

    InputStream is = getClass().getResourceAsStream("./dbinfo.properties");
    Properties dbProps = new Properties();
    try
    {
    dbProps.load(is);  
    url=dbProps.getProperty("dbc.url");
    username=dbProps.getProperty("dbc.username");
    password=dbProps.getProperty("dbc.password");
     
    }
    catch(Exception e)
    {
    System.out.println("Cannot load dbinfo.properties,"+
    "make sure this file is in the path that CLASSPATH defined.");
    return;
    }properties用来读取属性文件
    //dbinfo.properties
    dbc.url=....
    dbc.password=...
    ..