File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Read RTF File from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Read RTF File from Java" Watch "Read RTF File from Java" New topic
Author

Read RTF File from Java

sunilkumarbit choudhary
Greenhorn

Joined: Mar 31, 2008
Posts: 1
hello mam/sir
How cani read RTF file from java.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42919
    
  68
Welcome to JavaRanch.

That depends on what you want to do with the file contents. Fundamentally, RTF is just a text file, so you can use the File, FileInputStream and various Reader classes in the java.io package.

If you want to display RTF in a Swing component, have a look at this sample application which does exactly that.
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 863
    
    1
Originally posted by sunilkumarbit choudhary:
How can i read RTF file from java


Keep in mind that RTF is not really a standard. Microsoft documents it poorly and amends it whenever it sees fit. That said, reading an RTF file can be as easy as:

JEditorPane jep = new JEditorPane("application/rtf", "");
jep.read(new FileInputStream("path/to/file.rtf"), null);
yourContainer.add(new JScrollPane(jep));

I hope this is helpful.


bitguru blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read RTF File from Java