properties位于src目录下

project

    --src

         -----package

         -----test.properties

 

Properties p = new Properties();
//从输入流中读取属性列表(键和元素对)
p.load(DB.class.getClass().getResourceAsStream("/test.properties"));
String testKey = p.getProperty("testKey");

不能这样写

 File file = new File("src/test.properties");

输出路径为会带!   因为是jar包

 

 

java指定编码格式utf-8运行jar

java -Dfile.encoding=utf-8 -jar test.jar

 

相关文章:

  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2021-11-18
猜你喜欢
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
  • 2021-05-31
  • 2022-12-23
相关资源
相似解决方案