writeToFile static method

Future<void> writeToFile(
  1. String file,
  2. CompoundTag tag
)

Implementation

static Future<void> writeToFile(String file, CompoundTag tag) async {
  File handle = File(file);

  if (handle.existsSync())
    handle.deleteSync(); // Ensure we flush the file to 0 bytes

  StringBuilder builder = StringBuilder();
  Tag.writeStringifiedNamedTag(tag, builder, 0);
  await handle.writeAsString(builder.toString());
}