Created
January 10, 2012 14:55
-
-
Save anonymous/1589465 to your computer and use it in GitHub Desktop.
My simple Doc read program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.dream.textsplitter.io; | |
| import java.io.File; | |
| import java.io.FileInputStream; | |
| import org.apache.poi.hwpf.HWPFDocument; | |
| import org.apache.poi.hwpf.extractor.WordExtractor; | |
| public class DocReader { | |
| private String APP_FOLDER=DocReader.class.getProtectionDomain().getCodeSource().getLocation().getPath()+"../"; | |
| private String RELATIVE_DOC_PATH="ToSplit/TestDoc1.doc"; //OR TestDoc2.doc | |
| private String FULL_DOC_PATH=APP_FOLDER+RELATIVE_DOC_PATH; | |
| public void readDocFile() { | |
| File docFile = null; | |
| WordExtractor docExtractor = null ; | |
| try { | |
| docFile = new File(FULL_DOC_PATH); | |
| FileInputStream fis=new FileInputStream(docFile.getAbsolutePath()); | |
| HWPFDocument doc=new HWPFDocument(fis); | |
| docExtractor = new WordExtractor(doc); | |
| } | |
| catch(Exception exep) { | |
| System.out.println(exep.getMessage()); | |
| } | |
| //!!!!!!!! THIS IS WHERE THE ISSUE !!!!!!!!! | |
| System.out.println(docExtractor.getText().length()); | |
| } | |
| public static void main(String[] args) { | |
| DocReader reader = new DocReader(); | |
| reader.readDocFile(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This is my test text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This is my test text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment