DefaultStyledDocument styledDoc = new DefaultStyledDocument();
try {
new RTFEditorKit().read(is, styledDoc, 0);
bodyText = styledDoc.getText(0, styledDoc.getLength());
} catch (IOException e) {
throw new DocumentHandlerException(
"Cannot extract text from a RTF document", e);
} catch (BadLocationException e) {
throw new DocumentHandlerException(
"Cannot extract text from a RTF document", e);
}
if (bodyText != null) {
doc.addField("body", bodyText, StoreOption.COMPRESS, IndexOption.TOKENIZED);