开发者

close-group problem java RTFEditorKit

I am using a java RTFEditorKit that converts RTF to text most of the time. Some times, I will encounter a file where instead of the conversion taking place, I get the following:

java.io.IOException: Too many close-groups in RTF text at javax.swing.rtf.RTFParser.write(Unknown Source)

I've looked around the internet but don't see a ready solution to this problem.

Anybody else seen this and know what to 开发者_高级运维do?

Thank you,

Elliott


According to the code, this exception will be thrown if you have more closing braces than opening braces in your RTF. Sounds like your file is probably malformed.

Here is the code which throws the Exception:

else if(ch == '}') {
  if (currentCharacters.length() > 0) {
    handleText(currentCharacters.toString());
    currentCharacters = new StringBuffer();
  }
  if (level == 0)
    throw new IOException("Too many close-groups in RTF text");
  endgroup();
  level --;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜