在玩一个属性文件,我发现似乎有
最多只能保存40个字符。

我执行以下操作:

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.");

结果是,仅保存了前37个字符,并以“...”扩展。
我调试了PropertiesHash的正确值,写作
到文件似乎是问题所在。

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

tia
 K

最佳答案

没有这样的限制

由于您提到“...”,所以我有一个问题:您是否在JLabel中显示值?
“...”是JLabel渲染字符串过长的一种典型方式。

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

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

07-25 23:33
查看更多