Use Java to read data in Word

Source: Internet
Author: User

With Java simple reading data in Word documents: Step 1: Download tm-extractors-0.4.jar: http://drc-dev.ohiolink.edu/browser/elated-core/trunk/lib/tm-extractors-0.4.jar? REV = 46 and put it under your classpath path. Step 2: A simple program. (in front of wordreader .java.pdf, you have a strust.doc file under your edrive. Import java. Io. file;
Import java. Io. fileinputstream; import org. textmining. Text. extraction. wordextractor; public class wordreader {

Public static string readdoc (string DOC) throws exception {
// Create an input stream to read the DOC file
Fileinputstream in = new fileinputstream (new file (DOC ));
Wordextractor extractor = NULL;
String text = NULL;
// Create a wordextractor
Extractor = new wordextractor ();
// Extract the DOC file
TEXT = extractor. extracttext (in );
Return text;
}/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
// Todo auto-generated method stub
Try {
String text = wordreader. readdoc ("E:/strust.doc ");
System. Out. println (text );
} Catch (exception ex ){
Ex. printstacktrace ();
}
}
}
In this way, you can simply read data from the word. You can generate a TXT file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.