static void writeAccountsToFile(Path filepath, Collection<Account> accounts) throws IOException {
    try (FileChannel channel = FileChannel.open(filepath, StandardOpenOption.CREATE,
        StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE)) {
      ByteBuffer buffer = serializeAccounts(accounts);
      channel.write(buffer);
    } catch (IOException e) {
      // Failed to persist file
      logger.error("Failed to persist accounts to file {}", filepath, e);
      throw e;
    }
  }
Persist the account collection to the given file.
@param filepath The filepath to persist account map.
@param accounts The {@link Collection} of {@link Account}s
@throws IOException Any I/O error.
ambry-account/src/main/java/com/github/ambry/account/BackupFileManager.java