EditorCookieOrOpenCookie

File opening: EditorCookie or OpenCookie?

Adapted from: http://tdamir.blogspot.com/2008/02/file-opening-editorcookie-or-opencookie.html

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();

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo