java读取properties值

db.properties

id=007
name=\u5F20\u4E09

使用java读取db.properties中的值

public class Test02 {
	public static void main(String[] args) {
		Properties pro = new Properties();
		try {
			pro.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("db.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		System.out.println(pro.getProperty("id"));
		System.out.println(pro.getProperty("name"));
	}
}

在这里插入图片描述

发布了8 篇原创文章 · 获赞 0 · 访问量 162

猜你喜欢

转载自blog.csdn.net/weixin_44231438/article/details/104842811