下面列出了怎么用javax.swing.text.html.HTMLWriter的API类实例代码及写法,或者点击链接到github查看源代码。
private String getSelectionAsHTML() {
StringWriter buf = new StringWriter();
HTMLWriter writer = new HTMLWriter(buf,
(HTMLDocument)jTextPane.getDocument(), jTextPane.getSelectionStart(), jTextPane.getSelectionEnd());
try {
writer.write();
} catch (BadLocationException | IOException ex) {
ex.printStackTrace();
}
return buf.toString();
}