code: public static void writeFile(CompoundTag tag, File file, boolean compressed, boolean littleEndian) throws IOException {
          if(!file.exists()) {
              if(file.getParentFile() != null && !file.getParentFile().exists()) {
                  file.getParentFile().mkdirs();
              }
  
              file.createNewFile();
          }
  
          OutputStream out = new FileOutputStream(file);
          if(compressed) {
              out = new GZIPOutputStream(out);
          }
  
          writeTag(out, tag, littleEndian);
          out.close();
      }
docs: Writes the given root CompoundTag to the given file.
  
  @param tag          Tag to write.
  @param file         File to write to.
  @param compressed   Whether the NBT file should be compressed.
  @param littleEndian Whether to write little endian NBT.
  @throws java.io.IOException If an I/O error occurs.