Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem using RTFEditorKit

Gauri Horane
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everybody,
i want to read the text from the .rtf file.
i m using " javax.swing.text.rtf.RTFEditorKit";
i used the following code for that.
But for some .rtf files it worked finly but
for some .rtf files it throws the following Exception.
" Too many close-groups in RTF text"
while reding the .rtf file means at
in the following code.
can anybody tell me where is the problem & solution for it.


FileInputStream fin = new FileInputStream("FileName");
DataInputStream din = new DataInputStream(fin);

System.out.println("IN getFileName()():3333333333");

DefaultStyledDocument styledDoc = new DefaultStyledDocument();

System.out.println("IN getFileName()():4444444444444");

//Creating a RTF Editor kit
RTFEditorKit rtfKit = new RTFEditorKit();

//Populating the contents in the blank styled document,styledDoc,0);
Document doc = null;

doc = styledDoc.getDefaultRootElement().getDocument();

String str= doc.getText(0,doc.getLength());
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic