File opening: EditorCookie or OpenCookie?
Yesterday I wanted to create XML document in memory and open it. On Netbeans Wiki there is explanation and sample code for creating text file and opening it using OpenCookie. But the sample code does not work with XML documents. I debugged the code and noticed that XmlDataObject does not contain OpenCookie class. Instead we have to use EditorCookie. And EditorCookie also works with text files too. So maybe the sample code on Netbeans Wiki should be updated to following:
FileSystem fs = FileUtil.createMemoryFileSystem(); FileObject fob = fs.getRoot().createData(name, "txt"); DataObject data = DataObject.find(fob); EditorCookie cookie = (EditorCookie)data.getCookie(EditorCookie.class); cookie.open();