进阶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.util.Properties;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Properties与流相关的功能(从文件中读取键值对)(重点)
|
||||||
|
public void load(InputStream inStream): 从字节输入流中读取键值对。
|
||||||
|
|
||||||
|
操作步骤:
|
||||||
|
1.创建一个.properties的配置文件(它里面都是键值对)
|
||||||
|
2.创建Properties对象
|
||||||
|
3.调用Properties对象的load方法
|
||||||
|
*/
|
||||||
|
public class PropertiesDemo19 {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
Properties properties = new Properties();
|
||||||
|
|
||||||
|
FileInputStream fis = new FileInputStream("demo.properties");
|
||||||
|
properties.load(fis);
|
||||||
|
|
||||||
|
System.out.println(properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user