zoukankan      html  css  js  c++  java
  • Java properties | FileNotFoundException: properties (系统找不到指定的文件。)

    文件存储路径的问题

    错误描述 :FileNotFoundException: init.properties (系统找不到指定的文件。)

    1.方法一
    InputStream fis =TestProperties.class.getClassLoader().getResourceAsStream("init.properties")

    2.方法二(要求TestProperties和init.properties在同一目录下)
    InputStream fis =TestProperties.class搜索.getResourceAsStream("init.properties")

    推荐使用2。 放在TestProperties.java同级目录下面

    3.方法三,对于Web工程也可以这样。
    先获取ServletContext,然后
    InputStream in=context.getResourceAsStream("/WEB-INF/classes/init.properties");

  • 相关阅读:
    IE8、IE9解决浏览器跨域。
    英语写作-Introduction
    qt添加图标
    Qt 编译错误 :cannot find file .pro
    python
    数据集
    基金
    visio2010求交操作
    书籍网站
    ROS安装xtion
  • 原文地址:https://www.cnblogs.com/slankka/p/9158568.html
Copyright © 2011-2022 走看看