I am working on a bug in this program where it should be able to save the contents of a JTextPane to a formatted HTML file. The code that is currently there save a file containing just the tags but no content. The page appears blank but all the correct <p> and <font> tags are there with the correct colour set etc.
HTMLDocument htmlDoc = (HTMLDocument) output.getDocument();
FileWriter fw = new FileWriter(logFile);
HTMLWriter htmlWriter = new HTMLWriter(fw, htmlDoc);
htmlWriter.write();
fw.flush();
fw.close();
That is the code as it is currently. output is the JTextPane object. It doesn't seem right to be that the Document object returned from getDocument() is being casted directly into a HTMLDocument object.
Does anyone know what would make this work?