0

I have the below class which is using google guava map as you can see below , now the only query is that in it a list is been created as you can see but i want to keep this list in a properties file seprately since later on many new items will be added and deleted in this list so i want developer to only change the properties file

Below is the code

final Table<String, String, List<String>> values = HashBasedTable.create();
        values.put("Tbon", "cy", Lists.newArrayList("cat1","cat12","cat13","cat14"));
        values.put("Tbon", "ype", Lists.newArrayList("rat1","rat2","rat3"));

for (Cell<String, String, List<String>> cell: values.cellSet()){
            System.out.println(cell.getRowKey()+" "+cell.getColumnKey()+" "+cell.getValue());
        }

now as you can see both the array list are hardcoded here "cat1","cat12","cat13","cat14" and "rat1","rat2","rat3" but i want to keep thsese array list in a properties file seprately so that it can be map against row key so the properties file content will be like lets say name of the properties file is abc.properties stored in my local computer C: drive

    cy    cat1
    cy    cat12
    cy    cat13
    cy    cat14
    ype   rat1
    ype   rat2
    ype   rat3

so please advise if i keep this mappings in a properties filethen how they will be get called in the data structure values

1 Answers1

0

There is plenty of information on how to write property files on your disk on the internet, e.g. here: http://www.mkyong.com/java/java-properties-file-examples/

The default format assumes one value per key so you'll need some splitting and joining. Here's a simple answer to that issue: Multiple values in java.util.Properties

Community
  • 1
  • 1
Franz Becker
  • 705
  • 5
  • 8