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