JAVA操作properties文件

来源:互联网 发布:mysql 存储过程 循环 编辑:程序博客网 时间:2024/05/31 15:19
1.方法一(放在src的路径下)InputStream fis =TestProperties.class.getClassLoader().getResourceAsStream("init.properties")2.方法二(要求TestProperties和init.properties在同一目录下)InputStream fis =TestProperties.class.getResourceAsStream("init.properties")3.方法三,对于Web工程也可以这样。先获取ServletContext,然后InputStream in=context.getResourceAsStream("/WEB-INF/classes/init.properties");