// 获取类加载器
ClassLoader cl = JDBCUtils.class.getClassLoader();
// 获取文件的统一资源定位器对象
URL url = cl.getResource("db_config.properties");
// 获取文件的路径
String path = url.getPath();
Java编程中如何获取项目文件的路径/文件路径
关注
打赏
// 获取类加载器
ClassLoader cl = JDBCUtils.class.getClassLoader();
// 获取文件的统一资源定位器对象
URL url = cl.getResource("db_config.properties");
// 获取文件的路径
String path = url.getPath();
微信扫码登录