Read doc file in Java using POI

Source: Internet
Author: User

12345678910111213141516171819202122232425262728293031 Package com. Howto; import java. Io. FileInputStream; import java. Io. IOException; import org. Apache. Poi. HWPF. Hwpfdocument; /** Here we'll learn how to read a Doc file */public class readdocfile { Public static void main(String args[]) Throws IOException { /** Create input stream of the doc file-provide exact path of the doc* file to read */ fileinputstream fistream = new fileinputstream( "File_path"); hwpfdocument document = new hwpfdocument(fistream) ; System. Out. println("Length of Docment is:" + document. Characterlength()); System. Out. println(document. GetText()); System. Out. println(document. Getdocumenttext()); }}

Here we'll use the POI open source project to read Windows doc file. The PoI Jar would be required the can downloaded from Apache website.

Read doc file in Java using POI

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.