Properties(是一个特殊的Map)默认键值都是String类型
备注:Properties能调用Map中的所有方法,但由于放入Properties中的key-value都是String类型,Properties中提供了特殊的存值和取值的方法,所以尽量不要用Map中的方法,如下
Properties的作用
A、将内存中的数据写入到硬盘中【写入===下载,如网盘文件下载到磁盘中】
B、将硬盘中的数据读取到内存中【读取===上传,如磁盘文件上传到网盘中】
字段摘要
无
构造方法摘要
Properties()
创建一个无默认值的空属性列表
Properties(Properties defaults)
创建一个带有指定默认值的空属性列表
方法摘要
Object setProperty(String key, String value)
调用 Hashtable 的方法 put
public class PropertiesDemo {public static void main(String[] args) { Properties propertiesAAA = new Properties();propertiesAAA.setProperty("aa","1100W");System.out.println(propertiesAAA);//{aa=1100W}}
}
String getProperty(String key)
用指定的键在此属性列表中搜索属性
public class PropertiesDemo {public static void main(String[] args) {Properties propertiesAAA = new Properties();propertiesAAA.setProperty("aa","1100W");System.out.println(propertiesAAA.get("aa"));//1100W}
}
将内存中的数据写入到硬盘中
void list(PrintStr