获取src下的fileurl.properties文件路径

this.getClass().getResource("/fileurl.properties").getPath()

【this.getClass().getResourceAsStream("/"+Basic.dll);】----jar中的class获取jar内部的资源文件,该文件打包成jar前放置在src目录下

如果文件和读取类在同一个包下,把“/”去掉【this.getClass().getResourceAsStream(Basic.dll);】

获取webRoot下的service文件夹路径

request.getSession().getServletContext().getRealPath("/service");

解决路径中包含空格

URLDecoder.decode(this.getClass().getResource("/fileurl.properties").getPath(),"utf-8")

 

获取jar同级目录下的文件:例如System.getProperty("user.dir")+java.io.File.separator+“文件名”

相关文章:

  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2022-02-07
  • 2021-12-17
  • 2022-12-23
  • 2022-02-17
猜你喜欢
  • 2021-10-19
  • 2022-01-17
  • 2021-06-12
  • 2022-12-23
  • 2022-01-29
  • 2021-12-20
相关资源
相似解决方案