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()
删除标签。