image.png
    image.png

    1. package com.atguigu.java;
    2. import java.io.FileInputStream;
    3. import java.util.Properties;
    4. /**
    5. * @author Dxkstart
    6. * @create 2021-05-23 18:59
    7. */
    8. public class PropertiesTest {
    9. //Properties:常用来处理配置文件。key和value都是String类型
    10. public static void main(String[] args) throws Exception {
    11. Properties prop = new Properties();
    12. FileInputStream fil = new FileInputStream("jdbc.properties");
    13. prop.load(fil);//加载流对应文件
    14. String name = prop.getProperty("name");
    15. String password = prop.getProperty("password");
    16. System.out.println(name + password);
    17. }
    18. }
    1. name=Tom
    2. password=abc123