package com.briup.day13;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
public class PropertiesTest {
public static void main(String[] args) throws FileNotFoundException, IOException {
//1.查看jvm的配置信息
//Properties p = System.getProperties();
//在标准输出上输出数据
//p.list(System.out);
//查看系统某个属性
/*String p1 = p.getProperty("java.home");
System.out.println(p1);*/
//2.获取自己的信息
/*Properties pro=new Properties();
pro.load(new FileInputStream(new File("src/com/briup/day13/info.properties")));
//根据key或去value
String id = pro.getProperty("id");
String age=pro.getProperty("age");
String name = pro.getProperty("name");
System.out.println(id+":"+name+":"+age);*/
//3.直接存储和获取信息,key和value只能是字符串类型
Properties pro=new Properties();
pro.setProperty("aa","aaa");
pro.setProperty("bb","bbb");
String s = pro.getProperty("bb");
System.out.println(s);
}
}
Properties
最新推荐文章于 2024-11-12 21:14:07 发布