Converting RTF to ASCII text using RTFEditorKit

Main.java:

import javax.swing.text.rtf.*;
import javax.swing.text.*;
import java.io.*;
 
public class Main 
{
   public static void main(String []args) throws Exception {
      RTFEditorKit rtf = new RTFEditorKit();
      Document doc = rtf.createDefaultDocument();
 
      FileInputStream fis = new FileInputStream("c:\richtext.rtf");
      rtf.read(fis,doc,0);
      System.out.println(doc.getText(0,doc.getLength()));
   }
}

You can find the file richtext.rtf here.

Output:

 
This is rich text
 
This is RICH TEXT
 
THIS IS RICH TEXT
 
and if you don't believe it
 
I'll tell ya another fun story

Of course, you can also call an external program to do the conversion for you, eg. http://www.a2001.com/english/down/rtf.html