@Override
	public File exportTool(ToolTemplate tool) throws FileNotFoundException, IOException {

		File location = chooseToolFile(tool);
		if (location == null) {
			return location; // user cancelled
		}

		String filename = location.getName();
		if (!filename.endsWith(ToolUtils.TOOL_EXTENSION)) {
			filename = filename + ToolUtils.TOOL_EXTENSION;
		}

		try (FileOutputStream f =
			new FileOutputStream(location.getParent() + File.separator + filename)) {
			BufferedOutputStream bf = new BufferedOutputStream(f);
			Document doc = new Document(tool.saveToXml());
			XMLOutputter xmlout = new GenericXMLOutputter();
			xmlout.output(doc, bf);
		}

		return location;
	}
Implementation of service used to manipulate tools.
Ghidra/Framework/Project/src/main/java/ghidra/framework/project/tool/ToolServicesImpl.java