Java 读取 properties 文件

加载当前类路径下的 properties 文件

 

Properties properties = new Properties();
// 使用ClassLoader加载properties配置文件生成对应的输入流
InputStream in = 当前类名.class.getClassLoader().getResourceAsStream("emailConfig.properties");
// 使用properties对象加载输入流
properties.load(in);
//获取key对应的value值
account=properties.getProperty("account");
password=properties.getProperty("password");
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章