加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

属性文件字符串长度限制(JAVA)

发布时间:2020-12-15 05:22:05 所属栏目:Java 来源:网络整理
导读:玩一个属性文件,我认为似乎有 限制40char保存在单个属性中. 我做以下事情: File configFile = new File("config.properties");Properties props = new Properties();props.put( "cc_server","sort_of_a_long_string_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
玩一个属性文件,我认为似乎有
限制40char保存在单个属性中.

我做以下事情:

File configFile = new File("config.properties");

Properties props = new Properties();
props.put( "cc_server","sort_of_a_long_string_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
FileOutputStream fos = new FileOutputStream( configFile );
PrintWriter pw = new PrintWriter( fos );
props.list( pw );
pw.flush();
pw.close();         
System.out.println("done.");

结果是,只有第一个37char被保存,扩展为“…”.
我认为PropertiesHash有正确的价值,写作
到文件似乎是问题.

有没有办法扩展/关闭此限制?

TIA

K

解决方法

没有这样的限制

既然你提到“……”我有这个问题:你在JLabel中显示价值吗?
“…”是JLabel呈现String太长的典型方式.

还有一种更简单的方法来保存属性

File propertiesfile=new File("fileName.props");
propstosave.store(new FileOutputStream(propertiesfile),"groupnames");

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读