private void writeConfigFile(Properties propertiesToStore, boolean append) throws AmbariException {
    File configFile = null;
    try {
      configFile = getConfigFile();
      propertiesToStore.store(new OutputStreamWriter(new FileOutputStream(configFile, append), Charsets.UTF_8), null);
    } catch (Exception e) {
      LOG.error("Cannot write properties [" + propertiesToStore + "] into configuration file [" + configFile + ", " + append + "] ");
      throw new AmbariException("Error while clearing ambari.properties", e);
    }
  }
Writes the given properties into the configuration file

@param propertiesToWrite
         the properties to be stored
@param append
         if {@code true} the given properties will be added at the end of the
         configuration file; otherwise a brand new configuration file will be
         produced
@throws AmbariException
          if there was any issue when clearing ambari.properties
ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java