Java uses POI to get world file content

Source: Internet
Author: User

This article mainly introduces the use of POI packet, read the world file content.

This version of the problem still exists, can only read the doc end of the old version of the file.

Words don't say much, on the code:

1 ImportJava.io.File;2 ImportJava.io.FileInputStream;3 4 Importorg.apache.poi.hwpf.HWPFDocument;5 ImportOrg.apache.poi.hwpf.usermodel.Range;6 7 8  Public classTestdoc {9     /**Ten * Read doc file contents One      * @paramfile object to be read by file A      * @returnReturn file Contents -      */ -      Public StaticString doc2string (file file) { theString result = ""; -         Try{ -FileInputStream FIS =Newfileinputstream (file); -Hwpfdocument doc =Newhwpfdocument (FIS); +Range rang =Doc.getrange (); -Result + =Rang.text (); + fis.close (); A}Catch(Exception e) { at e.printstacktrace (); -         } -         returnresult; -     } -      Public Static voidMain (string[] args) { -File File =NewFile ("D:/lucenedata/test6.doc"); in System.out.println (doc2string (file)); -     } to}
Read file

Save Results

Read results

Required JAR Package

Java uses POI to get world file content

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.