code: public static void dumpToFile(File destination, boolean overwrite, Profile... profiles) {
          if (destination.exists() && !overwrite) {
              throw new SdkClientException(
                      "The destination file already exists. " +
                      "Set overwrite=true if you want to clobber the existing " +
                      "content and completely re-write the file.");
          }
  
          OutputStreamWriter writer;
          try {
              writer = new OutputStreamWriter(new FileOutputStream(destination, false), StringUtils.UTF8);
  
          } catch (IOException ioe) {
              throw new SdkClientException(
                      "Unable to open the destination file.", ioe);
          }
  
          try {
              final Map<String, Profile> modifications = new LinkedHashMap<String, Profile>();
              for (Profile profile : profiles) {
                  modifications.put(profile.getProfileName(), profile);
              }
              ProfilesConfigFileWriterHelper writerHelper = new ProfilesConfigFileWriterHelper(writer, modifications);
  
              writerHelper.writeWithoutExistingContent();
          } finally {
              try { writer.close(); } catch (IOException ioe) {}
          }
  
      }
docs: Write all the credential profiles to a file. Note that this method will
  clobber the existing content in the destination file if it's in the
  overwrite mode. Use {@link #modifyOrInsertProfiles(File, Profile...)}
  instead, if you want to perform in-place modification on your existing
  credentials file.
  
  @param destination
  The destination file where the credentials will be written to.
  @param overwrite
  If true, this method If false, this method will throw
  exception if the file already exists.
  @param profiles
  All the credential profiles to be written.