读取maven项目resources路径下的文件
适用于在IDE中运行项目
方式一:
URL url = 类名.class.getClassLoader().getResource("conf.properties"); File file = new File(url.getFile());
方式二:
InputStream is = 类名.class.getClassLoader().getResourceAsStream("conf.properties");
- - 补充 2020年11月18日 - - - - - - - - - - - - - - - - - - - - - - - - - - -
获取程序运行的根路径:
String path = 类名.class.getResource("/").getPath();

浙公网安备 33010602011771号