读取properties文件

来源:互联网 发布:java arraylist源码 编辑:程序博客网 时间:2024/06/03 20:57

在资源文件夹中创建文件test.properties

内容为name=over


读取改文件

public class Test2 {    public static void main(String[] args) throws IOException {        Properties p = new Properties();        p.load(Test2.class.getClassLoader().getResourceAsStream("test.properties"));        System.out.println(p.get("name"));    }}


输出:

over