This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Problem using RTFEditorKit Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Problem using RTFEditorKit" Watch "Problem using RTFEditorKit" New topic
Author

Problem using RTFEditorKit

Gauri Horane
Greenhorn

Joined: Mar 10, 2005
Posts: 7
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.
"java.io.IOException: Too many close-groups in RTF text"
while reding the .rtf file means at
line
" rtfKit.read(din,styledDoc,0);"
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
rtfKit.read(din,styledDoc,0);
Document doc = null;

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

String str= doc.getText(0,doc.getLength());
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Problem using RTFEditorKit
 
Similar Threads
Reading RTF File in Java
Problem using RTFEditorKit to make a WordProcessor Like WordPad in Windows
RTFEditorKit - underline not working
File Convertion
parsing .rtf file to a string