String rtfText; String rtfToHtml(Reader rtf) { JEditorPane p = new JEditorPane(); p.setContentType("text/rtf"); String htmlText = rtfToHtml(new FileReader(new File("myfile.rtf"))); EditorKit kitRtf = p.getEditorKitForContentType("text/rtf"); try { kitRtf.read(rtf, p.getDocument(), 0); kitRtf = null; EditorKit kitHtml = p.getEditorKitForContentType("text/html"); Writer writer = new StringWriter(); kitHtml.write(writer, p.getDocument(), 0, p.getDocument().getLength()); return writer.toString(); } catch (BadLocationException e) { e.printStackTrace(); } return null; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)