@Override
  public void flush() {
    XLog.i("flush");
    synchronized (sync) {
      try {
        Set<String> out = new HashSet<>();
        Object[] arrLocal = mStorage.toArray();
        CollectionUtils.consumeRemaining(arrLocal, o -> {
          String str = GsonUtils.GSON.toJson(o);
          out.add(str);
        });
        @Cleanup
        FileOutputStream fos = mFile.startWrite();
        XmlUtils.writeSetXml(out, fos);
        mFile.finishWrite(fos);
      } catch (Throwable e) {
        XLog.w("Fail flush@IOException: " + mFile + "\n" + Log.getStackTraceString(e));
      }
    }
  }
Created by guohao4 on 2017/12/11. Email: Tornaco@163.com
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/persist/JsonObjectSetRepo.java