java RTFEditorKit 闭群问题

发布于 2024-10-07 11:56:30 字数 281 浏览 0 评论 0原文

我大多数时候使用 java RTFEditorKit 将 RTF 转换为文本。有时,我会遇到一个文件,其中没有进行转换,而是得到以下信息:

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

我浏览了互联网,但没有看到这个问题的现成解决方案。

还有其他人看到过这个并知道该怎么做吗?

谢谢你,

埃利奥特

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘年祭陌 2024-10-14 11:56:30

根据代码,如果 RTF 中右大括号的数量多于左大括号的数量,则会抛出此异常。听起来您的文件可能格式错误。

这是抛出异常的代码:

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 --;
}

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 --;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文