欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 旅游 > Properties配置文件

Properties配置文件

2025/4/26 3:27:44 来源:https://blog.csdn.net/qq_54354111/article/details/147409728  浏览:    关键词:Properties配置文件

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

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词