javax.swing.text.html.HTMLEditorKit.write()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中javax.swing.text.html.HTMLEditorKit.write()方法的一些代码示例,展示了HTMLEditorKit.write()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HTMLEditorKit.write()方法的具体详情如下:
包路径:javax.swing.text.html.HTMLEditorKit
类名称:HTMLEditorKit
方法名:write

HTMLEditorKit.write介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

  1. String rtf = [your document rich text];
  2. BufferedReader input = new BufferedReader(new StringReader(rtf));
  3. RTFEditorKit rtfKit = new RTFEditorKit();
  4. StyledDocument doc = (StyledDocument) rtfKit.createDefaultDocument();
  5. rtfEdtrKt.read( input, doc, 0 );
  6. input.close();
  7. HTMLEditorKit htmlKit = new HTMLEditorKit();
  8. StringWriter output = new StringWriter();
  9. htmlKit.write( output, doc, 0, doc.getLength());
  10. String html = output.toString();

代码示例来源:origin: stackoverflow.com

  1. String rtf = "whatever";
  2. BufferedReader input = new BufferedReader(new StringReader(rtf));
  3. RTFEditorKit rtfKit = new RTFEditorKit();
  4. StyledDocument doc = (StyledDocument) rtfKit.createDefaultDocument();
  5. rtfEdtrKt.read( input, doc, 0 );
  6. input.close();
  7. HTMLEditorKit htmlKit = new HTMLEditorKit();
  8. StringWriter output = new StringWriter();
  9. htmlKit.write( output, doc, 0, doc.getLength());
  10. String html = output.toString();

代码示例来源:origin: com.eas.platypus/platypus-js-forms

  1. w.write();
  2. } else {
  3. super.write(out, doc, pos, len);

代码示例来源:origin: stackoverflow.com

  1. if (textPaneHistory.getText().length() > 0){
  2. JFileChooser chooser = new JFileChooser();
  3. chooser.setMultiSelectionEnabled(false);
  4. int option = chooser.showSaveDialog(ChatGUI.this);
  5. if (option == JFileChooser.APPROVE_OPTION) {
  6. StyledDocument doc = (StyledDocument)textPaneHistory.getDocument();
  7. HTMLEditorKit kit = new HTMLEditorKit();
  8. BufferedOutputStream out;
  9. try {
  10. out = new BufferedOutputStream(new FileOutputStream(chooser.getSelectedFile().getAbsoluteFile()));
  11. kit.write(out, doc, doc.getStartPosition().getOffset(), doc.getLength());
  12. } catch (FileNotFoundException e) {
  13. } catch (IOException e){
  14. } catch (BadLocationException e){
  15. }
  16. }
  17. }

代码示例来源:origin: org.eclipse.scout.rt/org.eclipse.scout.commons

  1. /**
  2. * @deprecated Will be removed with scout 7.
  3. */
  4. @Deprecated
  5. public static String toHtmlText(HTMLDocument doc) {
  6. String htmlText = "";
  7. if (doc == null) {
  8. return htmlText;
  9. }
  10. try {
  11. HTMLEditorKit kit = new HTMLEditorKit();
  12. StringWriter buf = new StringWriter();
  13. kit.write(buf, doc, 0, doc.getLength());
  14. htmlText = buf.toString();
  15. }
  16. catch (Throwable t) {
  17. LOG.error("failed to extract HTML text from HTML document", t);
  18. }
  19. return htmlText;
  20. }

代码示例来源:origin: stackoverflow.com

  1. HTMLEditorKit tmp = new HTMLEditorKit();
  2. HTMLDocument doc = (HTMLDocument) tmp.createDefaultDocument();
  3. StringWriter writer = new StringWriter();
  4. tmp.write(writer, doc, 0, doc.getLength());
  5. String s = writer.toString();
  6. console.log(s);

代码示例来源:origin: girtel/Net2Plan

  1. @Override
  2. public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException
  3. {
  4. if (doc instanceof HTMLDocument)
  5. {
  6. FixedHTMLWriter w = new FixedHTMLWriter(out, (HTMLDocument) doc, pos, len);
  7. w.write();
  8. }
  9. else if (doc instanceof StyledDocument)
  10. {
  11. MinimalHTMLWriter w = new MinimalHTMLWriter(out, (StyledDocument) doc, pos, len);
  12. w.write();
  13. }
  14. else
  15. {
  16. super.write(out, doc, pos, len);
  17. }
  18. }

代码示例来源:origin: stackoverflow.com

  1. kit.write(w, field.getDocument(), field.getSelectionStart(), field.getSelectionEnd()-field.getSelectionStart());
  2. System.out.println(w.toString());
  3. } catch (IOException | BadLocationException ex) {

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

  1. public void write(Writer out, Document doc, int pos, int len)
  2. throws IOException, BadLocationException
  3. {
  4. if (doc instanceof HTMLDocument)
  5. {
  6. NoLinefeedHtmlWriter w = new NoLinefeedHtmlWriter(out,
  7. (HTMLDocument) doc, pos, len);
  8. // the default behavior of write() was to setLineLength(80) which resulted in
  9. // the inserting or a CR/LF around the 80ith character in any given
  10. // line. This was not good because if a merge tag was in that range, it would
  11. // insert CR/LF in between the merge tag and then the replacement of
  12. // merge tag with bean values was not working.
  13. w.setLineLength(Integer.MAX_VALUE);
  14. w.write();
  15. }
  16. else if (doc instanceof StyledDocument)
  17. {
  18. MinimalHTMLWriter w = new MinimalHTMLWriter(out,
  19. (StyledDocument) doc, pos, len);
  20. w.write();
  21. }
  22. else
  23. {
  24. super.write(out, doc, pos, len);
  25. }
  26. }
  27. }

代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx

  1. public void write(Writer out, Document doc, int pos, int len)
  2. throws IOException, BadLocationException
  3. {
  4. if (doc instanceof HTMLDocument)
  5. {
  6. NoLinefeedHtmlWriter w = new NoLinefeedHtmlWriter(out,
  7. (HTMLDocument) doc, pos, len);
  8. // the default behavior of write() was to setLineLength(80) which resulted in
  9. // the inserting or a CR/LF around the 80ith character in any given
  10. // line. This was not good because if a merge tag was in that range, it would
  11. // insert CR/LF in between the merge tag and then the replacement of
  12. // merge tag with bean values was not working.
  13. w.setLineLength(Integer.MAX_VALUE);
  14. w.write();
  15. }
  16. else if (doc instanceof StyledDocument)
  17. {
  18. MinimalHTMLWriter w = new MinimalHTMLWriter(out,
  19. (StyledDocument) doc, pos, len);
  20. w.write();
  21. }
  22. else
  23. {
  24. super.write(out, doc, pos, len);
  25. }
  26. }
  27. }

相关文章