Properties properties=new Properties(); //读取properties文件
// InputStream inputStream=new FileInputStream(new File("src/property.properties")); 文件在src目录下
InputStream inputStream=JdbcUtil.class.getClassLoader().getResourceAsStream("property.properties"); //使用classLoader加载classpath路径
properties.load(inputStream);
String str=(String) properties.get("JdbcUtil");
Class c=Class.forName(str);
读取properties文件和类加载器
本文介绍了如何使用Java来读取properties配置文件,并通过不同的方式加载文件,包括从src目录下直接读取和使用ClassLoader从classpath路径加载。

被折叠的 条评论
为什么被折叠?



