Property Line Length Limit (JAVA)

playing with the properties file, I realized that there seems to be a 40char limit for saving in a single property.

I do the following:

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

The result is that only the first 37char are saved, expanded by "...". I was debugging that PropertiesHash got the correct values, writing to the file seems to be the problem.

Is there any way to extend / disable this restriction?

TIA

 K
+3
source share
2 answers

There is no such limit

Since you mention "...", I have this question: are you showing the value in JLabel? "..." is a typical JLabel way of playing a string that is too long.

There is also an easier way to save properties.

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

. list() , store():

File configFile = new File("config.properties");
Properties props = new Properties();
props.put("cc_server", "sort_of_a_long_string_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
props.store(new FileOutputStream(configFile),"aaa");
+12

Source: https://habr.com/ru/post/1714760/


All Articles