【发布时间】:2013-07-16 09:23:34
【问题描述】:
package htmldocsave;
import java.io.IOException;
import javax.swing.text.BadLocationException;
import javax.swing.text.html.*;
import java.io.*;
public class HTMLDocSave
{
public static void main(String[] args)
{
HTMLDocument doc = new HTMLDocument();
HTMLEditorKit kit = new HTMLEditorKit();
File f = new File("greeting.html");
try
{
kit.insertHTML(doc,doc.getLength(),"<b>Hello</b>",0,0,null);
FileOutputStream fos = new FileOutputStream(f);
???????????????????????????
fos.close();
}
catch (BadLocationException | IOException e)
{
e.printStackTrace();
}
}
}
如何在文件系统上保存 HTML 文档? javax.swing.text.html.HTMLDocument 类不会覆盖toString() 方法,getText() 会删除标签。
【问题讨论】:
标签: java swing dom htmleditorkit