Solved

RTF2Text

Posted on 2004-04-06
3
386 Views
Last Modified: 2012-06-27
Hi all
How to get the text from RTF document

are there any API available for this?


Thanks
P
0
Comment
Question by:lakkiprasanna
3 Comments
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 20 total points
ID: 10763760
Just Discussed in Some other Thread

import javax.swing.text.rtf.RTFEditorKit;
import javax.swing.text.*;
import java.io.*;
class RTF2Text
{
      public static void main(String[] args) throws Exception
      {
            System.out.println(getText(args[0]));
      }
      public static String getText(String file) throws Exception
      {
            FileInputStream stream = new FileInputStream(file);
            RTFEditorKit kit = new RTFEditorKit();
            javax.swing.text.Document doc = kit.createDefaultDocument();
            kit.read(stream, doc, 0);

            String plainText = doc.getText(0, doc.getLength());
            return plainText;



      }
}
0
 
LVL 30

Expert Comment

by:mayankeagle
ID: 10764379
0
 

Author Comment

by:lakkiprasanna
ID: 10764484
thanks

that worked for me
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Updating Java 9 87
parentbit challenge 3 52
Java / Linux and Regular Expressions 11 47
GUI builder for Eclipse? 8 11
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now