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")); // } }