package Map;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
/**
*
*
* @author
* @create 2022-04-23-10:40
*/
public class PropertiesTest {
//Properties:常用来处理配置文件。key和value都是String类型
public static void main(String[] args) {
FileInputStream fis = null;
try {
Properties pros = new Properties();
fis = new FileInputStream("jdbc.properties");
pros.load(fis);//加载流对应的文件
String name = pros.getProperty("name");
String age = pros.getProperty("age");
System.out.println("name="+name+"age="+age);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fis!=null){
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
name=Tom浙江大学
age=23