1 1.方法一 
 2 InputStream fis =TestProperties.class.getClassLoader().getResourceAsStream(“init.properties”)
 3 
 4 2.方法二(要求TestProperties和init.properties在同一目录下) 
 5 InputStream fis =TestProperties.class.getResourceAsStream(“init.properties”)
 6 
 7 3.方法三,对于Web工程也可以这样。 
 8 先获取ServletContext,然后 
 9 
10 InputStream in=context.getResourceAsStream(“/WEB-INF/classes/init.properties”);

 

相关文章:

  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2022-03-04
  • 2021-11-29
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-08
  • 2021-12-31
  • 2021-09-18
  • 2021-11-05
  • 2021-10-05
  • 2022-12-23
相关资源
相似解决方案