code: public void writeTag(Tag<?> tag) throws IOException {
          String name = tag.getName();
          byte[] nameBytes = name.getBytes(NBTConstants.CHARSET.name());
  
          os.writeByte(tag.getType().getId());
          os.writeShort(nameBytes.length);
          os.write(nameBytes);
  
          if (tag.getType() == TagType.TAG_END) {
              throw new IOException("Named TAG_End not permitted.");
          }
  
          writeTagPayload(tag);
      }
docs: Writes a tag.
  
  @param tag The tag to write.
  @throws java.io.IOException if an I/O error occurs.