本文整理了Java中javax.swing.text.html.HTMLEditorKit.write()
方法的一些代码示例,展示了HTMLEditorKit.write()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HTMLEditorKit.write()
方法的具体详情如下:
包路径:javax.swing.text.html.HTMLEditorKit
类名称:HTMLEditorKit
方法名:write
暂无
代码示例来源:origin: stackoverflow.com
String rtf = [your document rich text];
BufferedReader input = new BufferedReader(new StringReader(rtf));
RTFEditorKit rtfKit = new RTFEditorKit();
StyledDocument doc = (StyledDocument) rtfKit.createDefaultDocument();
rtfEdtrKt.read( input, doc, 0 );
input.close();
HTMLEditorKit htmlKit = new HTMLEditorKit();
StringWriter output = new StringWriter();
htmlKit.write( output, doc, 0, doc.getLength());
String html = output.toString();
代码示例来源:origin: stackoverflow.com
String rtf = "whatever";
BufferedReader input = new BufferedReader(new StringReader(rtf));
RTFEditorKit rtfKit = new RTFEditorKit();
StyledDocument doc = (StyledDocument) rtfKit.createDefaultDocument();
rtfEdtrKt.read( input, doc, 0 );
input.close();
HTMLEditorKit htmlKit = new HTMLEditorKit();
StringWriter output = new StringWriter();
htmlKit.write( output, doc, 0, doc.getLength());
String html = output.toString();
代码示例来源:origin: com.eas.platypus/platypus-js-forms
w.write();
} else {
super.write(out, doc, pos, len);
代码示例来源:origin: stackoverflow.com
if (textPaneHistory.getText().length() > 0){
JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(false);
int option = chooser.showSaveDialog(ChatGUI.this);
if (option == JFileChooser.APPROVE_OPTION) {
StyledDocument doc = (StyledDocument)textPaneHistory.getDocument();
HTMLEditorKit kit = new HTMLEditorKit();
BufferedOutputStream out;
try {
out = new BufferedOutputStream(new FileOutputStream(chooser.getSelectedFile().getAbsoluteFile()));
kit.write(out, doc, doc.getStartPosition().getOffset(), doc.getLength());
} catch (FileNotFoundException e) {
} catch (IOException e){
} catch (BadLocationException e){
}
}
}
代码示例来源:origin: org.eclipse.scout.rt/org.eclipse.scout.commons
/**
* @deprecated Will be removed with scout 7.
*/
@Deprecated
public static String toHtmlText(HTMLDocument doc) {
String htmlText = "";
if (doc == null) {
return htmlText;
}
try {
HTMLEditorKit kit = new HTMLEditorKit();
StringWriter buf = new StringWriter();
kit.write(buf, doc, 0, doc.getLength());
htmlText = buf.toString();
}
catch (Throwable t) {
LOG.error("failed to extract HTML text from HTML document", t);
}
return htmlText;
}
代码示例来源:origin: stackoverflow.com
HTMLEditorKit tmp = new HTMLEditorKit();
HTMLDocument doc = (HTMLDocument) tmp.createDefaultDocument();
StringWriter writer = new StringWriter();
tmp.write(writer, doc, 0, doc.getLength());
String s = writer.toString();
console.log(s);
代码示例来源:origin: girtel/Net2Plan
@Override
public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException
{
if (doc instanceof HTMLDocument)
{
FixedHTMLWriter w = new FixedHTMLWriter(out, (HTMLDocument) doc, pos, len);
w.write();
}
else if (doc instanceof StyledDocument)
{
MinimalHTMLWriter w = new MinimalHTMLWriter(out, (StyledDocument) doc, pos, len);
w.write();
}
else
{
super.write(out, doc, pos, len);
}
}
代码示例来源:origin: stackoverflow.com
kit.write(w, field.getDocument(), field.getSelectionStart(), field.getSelectionEnd()-field.getSelectionStart());
System.out.println(w.toString());
} catch (IOException | BadLocationException ex) {
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
public void write(Writer out, Document doc, int pos, int len)
throws IOException, BadLocationException
{
if (doc instanceof HTMLDocument)
{
NoLinefeedHtmlWriter w = new NoLinefeedHtmlWriter(out,
(HTMLDocument) doc, pos, len);
// the default behavior of write() was to setLineLength(80) which resulted in
// the inserting or a CR/LF around the 80ith character in any given
// line. This was not good because if a merge tag was in that range, it would
// insert CR/LF in between the merge tag and then the replacement of
// merge tag with bean values was not working.
w.setLineLength(Integer.MAX_VALUE);
w.write();
}
else if (doc instanceof StyledDocument)
{
MinimalHTMLWriter w = new MinimalHTMLWriter(out,
(StyledDocument) doc, pos, len);
w.write();
}
else
{
super.write(out, doc, pos, len);
}
}
}
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
public void write(Writer out, Document doc, int pos, int len)
throws IOException, BadLocationException
{
if (doc instanceof HTMLDocument)
{
NoLinefeedHtmlWriter w = new NoLinefeedHtmlWriter(out,
(HTMLDocument) doc, pos, len);
// the default behavior of write() was to setLineLength(80) which resulted in
// the inserting or a CR/LF around the 80ith character in any given
// line. This was not good because if a merge tag was in that range, it would
// insert CR/LF in between the merge tag and then the replacement of
// merge tag with bean values was not working.
w.setLineLength(Integer.MAX_VALUE);
w.write();
}
else if (doc instanceof StyledDocument)
{
MinimalHTMLWriter w = new MinimalHTMLWriter(out,
(StyledDocument) doc, pos, len);
w.write();
}
else
{
super.write(out, doc, pos, len);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!