title: Update properties files when there're up-to-date data
body: <p>I have a Map that contains key:value data for properties that are in different properties files. I came to the following solution:</p>
  
  <pre><code>//firstProp - properties file
  //FIRST_PROPERTIES_FILE - path to a properties file
  public void changeProps(Map&lt;String, String&gt; props) {
      boolean isFirstPropsChanged = false;
      boolean isSecondPropsChanged = false;
      boolean isThirdPropsChanged = false;
  
      Set&lt;String&gt; keys = props.keySet();
      for(String key : keys) {
          if(firstProp.containsKey(key) &amp;&amp; !firstProp.getProperty(key).equals(props.get(key))) {
              firstProp.setProperty(key, props.get(key));
              if(!isDirstPropsChanged) {
                  isFirstPropsChanged = true;
              }
          }
  
          if(secondProp.containsKey(key) &amp;&amp; !secondProp.getProperty(key).equals(props.get(key))) {
              secondProp.setProperty(key, props.get(key));
              if(!isSecondPropsChanged) {
                  isSecondPropsChanged = true;
              }
          }
  
          if(thirdProp.containsKey(key) &amp;&amp; !thirdProp.getProperty(key).equals(props.get(key))) {
              thirdProp.setProperty(key, props.get(key));
              if(!isThirdPropsChanged) {
                  isThirdPropsChanged = true;
              }
          }
      }
      try {
          if(isFirstPropsChanged){
              firstProp.store(new FileOutputStream(FIRST_PROPERTIES_FILE), null);
          }
          if(isSecondPropsChanged) {
              secondProp.store(new FileOutputStream(SECOND_PROPERTIES_FILE), null);
          }
          if(isThirdPropsChanged) {
              thirdProp.store(new FileOutputStream(THIRD_PROPERTIES_FILE), null);
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>This solution works well, but it looks like wheelchair. I looked through different DPs, Strategy seemed to be good here, but it only seemed... I even think that no DP should be applied and that there's much delicate and simpler solution. But what it is in fact?</p>
  
  <p><strong>Updated</strong>
  Refactoring according to Brian Agnew suggestion or smth. alike.</p>
  
  <pre><code>//Map&lt;Properties, File&gt; propertiesFileMap - Properties files with File they are located at.
  public void changePropsArray(Map&lt;String, String&gt; props) {
      Set&lt;String&gt; keys = props.keySet();
      for(String key : keys) {
          for(Properties prop : propertiesFileMap.keySet()) {
              if(prop.containsKey(key) &amp;&amp; !prop.getProperty(key).equals(props.get(key))) {
                  prop.setProperty(key, props.get(key));
              }
          }
      }
  
      try {
          for(Map.Entry&lt;Properties, File&gt; entry : propertiesFileMap.entrySet()) {
              entry.getKey().store(new FileOutputStream(entry.getValue()), null);
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>