@Override
        protected void onEndOfFile() {
            // Append profiles that don't exist in the original file
            for (Entry<String, Profile> entry : newProfiles.entrySet()) {
                String profileName = entry.getKey();
                Profile profile    = entry.getValue();

                if ( !existingProfileProperties.containsKey(profileName) ) {
                    // The profile name is not found in the file
                    // Append the profile properties
                    writeProfile(profile);
                    writeLine("");
                }
            }

            // Flush the "real" writer
            try {
                writer.flush();
            } catch (IOException ioe) {
                throw new SdkClientException(
                        "Unable to write to the target file to persist the profile credentials.",
                        ioe);
            }
        }
Read the existing content of a credentials file, and then make
in-place modification according to the new profiles specified in this
class.
aws-java-sdk-core/src/main/java/com/amazonaws/auth/profile/ProfilesConfigFileWriter.java