title: Java: Append Value to Property Key
body: <p>I am using java.util.Properties to store properties in a file. I am able to store key/value pair successfully using the following code:</p>
  
  <pre><code>public String setKeyValue(String dir, String key, String value) throws FileNotFoundException, IOException
  {
      File file = new File(dir);
  
  
      FileInputStream in = new FileInputStream(file);
      Properties properties = new Properties();
      properties.load(in);
      in.close();
  
      FileOutputStream out = new FileOutputStream(file);
      properties.setProperty(key, value);
      properties.store(out, null);
      out.close();
  
      String myValue = (String) properties.getProperty(key);
      System.out.println (myValue);
      return myValue;
  }
  </code></pre>
  
  <p>However, I am interested in updating (not replacing) a previous property so I can later retrieve them as an array. </p>
  
  <p>For example my current property looks something like this: </p>
  
  <pre><code>email=email1 
  </code></pre>
  
  <p>I want to change it to </p>
  
  <pre><code>email=email1, email2 //(this will be a continuous process of adding more emails)
  </code></pre>
  
  <p>This way I can later retrieve them as follows:</p>
  
  <pre><code>String[] emailList = properties.getProperty("email").split(","); 
  </code></pre>
  
  <p>If you use the previous code it simply replaces the property. I need to append additional "value" to key..</p>