package com.lovecoding.day20.map01;

import org.junit.Test;

import java.io.InputStream;
import java.util.Properties;

public class TestProperties03 {


    @Test
    public void test02() throws Exception {
        Properties properties = new Properties();
        //类加对象加载文件
        InputStream resourceAsStream = TestProperties03.class.getClassLoader().getResourceAsStream("path.properties");
        //读取文件
        properties.load(resourceAsStream);
        //输出
        System.out.println(properties);
        //获取key
        String person = properties.getProperty("person");
        //获取的Person类型对象
        Class<?> aClass = Class.forName(person);
        //实例对象
        Object o = aClass.newInstance();
        //输出
        System.out.println(o);

    }

    @Test
    public void test01(){

        Properties properties = new Properties();
        properties.put("user","zs");
        properties.put("pass","123456");

        Object user = properties.get("user");
        Object pass = properties.get("pass");

        System.out.println("用户名："+user);
        System.out.println("密码："+pass);

    }

}
