dcsimg

How do we save the modifications made to a HTML file using JEditorPane?

Sandip Chitale


// Say - editorPane is your JEditorPane
try {
  FileWriter writer = new FileWriter("file.html");
  EditorKit kit = editorPane.getEditorKit();

  kit.write(writer
            ,editorPane.getDocument()
            ,0
            ,editorPane.getDocument().getLength());

} catch (Exception e) { //use better exception catching here
  System.err.println(e);
}