Hi,
I've got a problem while parsing RTF file with RTFEditorKit. It throws an exception saying "Too many close-groups in RTF text". I've tried to open the document in MS Word and it worked just fine.
I guess that the document is malformed somehow, but MS Word just ignores the case while RTFEditorKit fails. Is there any solution about this issue? I've googled a bit but there's nothing useful on the subject.
Here is my code
RTFEditorKit rtf = new RTFEditorKit();
FileInputStream fi = new FileInputStream("test.rtf");
Document doc = rtf.createDefaultDocument();
rtf.read(fi, doc, 0);
String plainText = new String(doc.getText(0, doc.getLength()).getBytes("ISO-8859-1"), "cp1251");
System.out.println(plainText);
Maybe there is other open source API for RTF parsing? All I need - is just extract plain text data from RTF.