s-day09--Properties与流相关的功能(从文件中读取键值对)(重点)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.inmind.properties06;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/*
|
||||
20.Properties与流相关的功能(从文件中读取键值对)(重点)
|
||||
|
||||
void load(InputStream inStream) 从输入字节流读取属性列表(键和元素对)。
|
||||
*/
|
||||
public class Demo17 {
|
||||
public static void main(String[] args) throws IOException {
|
||||
//创建属性集对象
|
||||
Properties properties = new Properties();
|
||||
//创建字节输入流,绑定配置文件
|
||||
FileInputStream fis = new FileInputStream("demo.properties");
|
||||
//加载配置文件
|
||||
properties.load(fis);
|
||||
|
||||
System.out.println(properties);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user