tag:blogger.com,1999:blog-7296247505337716981.post3305554033059578488..comments2023-06-01T10:46:21.407-04:00Comments on nofoe: How to store an array in a Java properties fileJoe Hopkinshttp://www.blogger.com/profile/18358601813214869475noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-7296247505337716981.post-43099432390774915092014-08-11T12:36:21.724-04:002014-08-11T12:36:21.724-04:00Dumb code.
Say a.length is 15, because you have 1...Dumb code.<br /><br />Say a.length is 15, because you have 15 2-element entries.<br /><br />String[][] array = new String[a.length][a.length];<br /><br />creates 15 15-entry arrays, then inside the loop:<br /><br />array[i] = a[i].split(",");<br /><br />throws away each 15-element empty array in favor of a new 2-element one. <br /><br />Better to make the first line:<br /><br />String [][] array = new String[15][];<br /><br />No need to fill-in the second dimension as you're planing on inserting those in the loop.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7296247505337716981.post-29468985594350816142013-05-07T15:24:50.562-04:002013-05-07T15:24:50.562-04:00Harrisburg is the capital of Pennsylvania, not Phi...Harrisburg is the capital of Pennsylvania, not PhiladelphiaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7296247505337716981.post-37259732249997362332009-10-20T05:44:21.059-04:002009-10-20T05:44:21.059-04:00Anonymous is wrong.
He/she is referring to featur...Anonymous is wrong.<br /><br />He/she is referring to features only available in Apache Commons libraries. Sun's Java libraries don't offer anything like getStringArray() on resource bundle implementations.<br /><br />See also:<br /><br />http://java.sun.com/javase/6/docs/api/java/util/Properties.html<br /><br />http://commons.apache.org/configuration/userguide/howto_basicfeatures.htmlTobias W.https://www.blogger.com/profile/05835683559308939768noreply@blogger.comtag:blogger.com,1999:blog-7296247505337716981.post-61126245350752973012009-08-20T04:43:33.704-04:002009-08-20T04:43:33.704-04:00# chart colors
colors.pie = #FF0000, #00FF00, #000...# chart colors<br />colors.pie = #FF0000, #00FF00, #0000FF<br /><br />You don't have to split the value manually, you can retrieve an array or a java.util.List directly with:<br /><br />String[] colors = config.getStringArray("colors.pie");<br />List colorList = config.getList("colors.pie");<br /><br />Alternatively, you can specify a list of values in your properties file by using the same key on several lines:<br /><br /># chart colors<br />colors.pie = #FF0000;<br />colors.pie = #00FF00;<br />colors.pie = #0000FF;<br /><br />All of the features related to list handling described for AbstractConfiguration also apply to properties files, including changing the list delimiter or disabling list handling at all.Anonymousnoreply@blogger.com