java读取.properties配置文件

文件位置:

文件内容:

代码:

public class Test{
    public static void main (String[] args) throws IOException{
        Properties pro = new Properties();
        FileInputStream in =null;
        try{
            in = new FileInputStream("config\\db.properties");
        }catch (FileNotFoundException e){
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        pro.load(in);
        System.out.println (pro.getProperty ("driverName"));
        
//       
    }
}

  

posted @ 2015-01-23 11:06  大漠神驼  阅读(180)  评论(0编辑  收藏  举报