Servlet读取配置文件--非servlet下
public class TestDao { public void update() throws IOException { String url = TestDao.class.getClassLoader() .getResource("cn/linson/dao/db.properties").getPath(); System.out.println(url); FileInputStream fis = new FileInputStream(url); Properties pro = new Properties(); pro.load(fis); System.out.println(pro.getProperty("name")); } }

浙公网安备 33010602011771号