12345678910111213141516171819202122232425262728293031 |
- package J20250728;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.Properties;
- import java.util.Set;
- /**
- * @author WanJl
- * @version 1.0
- * @title Demo07_Properties
- * @description
- * @create 2025/7/28
- */
- public class Demo07_Properties {
- public static void main(String[] args) throws IOException {
- //创建集合
- Properties prop=new Properties();
- //创建字符输入流
- FileReader fr=new FileReader("myfile.properties");
- //加载文件中的键值对属性列表
- prop.load(fr);
- //遍历集合
- Set<String> names = prop.stringPropertyNames();
- for (String key : names){
- String value = prop.getProperty(key);
- System.out.println(key+"==>"+value);
- }
- }
- }
|