读取rtf文件内容时出错

时间:2015-10-12 12:21:23

标签: java

从RTF文件中提取内容时出现以下错误。

  

javax.swing.text.rtf.RTFReader $ AttributeTrackingDestination.handleKeyword(RTFReader.java:1279)

提取代码

JEditorPane p = null;
EditorKit rtfKit = null;
EditorKit txtKit = null;
Writer writer = null;
int[] filesCount = null;
try {

    p = new JEditorPane();
    p.setContentType("text/rtf");
    rtfKit =   p.getEditorKitForContentType("text/rtf");
    rtfKit.read(new FileReader(fileName), p.getDocument(), 0);

    rtfKit = null;

    txtKit = p.getEditorKitForContentType("text/plain");
    writer = new StringWriter();
    txtKit.write(writer, p.getDocument(), 0,   p.getDocument().getLength());
    String paragraphs = writer.toString();

0 个答案:

没有答案