A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 李迪   /  2011-7-23 14:29  /  2270 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

为何properties.store方法存储properties对象中的内容,每个属性和关键字必须用string类型,要么就发生异常?

评分

参与人数 1技术分 +1 收起 理由
小龙 + 1

查看全部评分

2 个回复

倒序浏览
黑马网友  发表于 2011-7-23 14:55:15
沙发
属性文件中每个属性是用字符串表示的
public void store(OutputStream out,String comments) throws IOException
方法定义时已经声明是String类型了,你再给他传递非String 类型的当然要发生异常

评分

参与人数 1技术分 +1 收起 理由
小龙 + 1 是这样?

查看全部评分

回复 使用道具 举报

关于Properties

查阅JDK,发现有个原因:
Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object.
Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings.
[ 本帖最后由 孙斌 于 2011-07-23  15:05 编辑 ]

评分

参与人数 1技术分 +1 收起 理由
小龙 + 1 勉强加分

查看全部评分

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马