/InteligentSearch/src/file_parser/WORDParserImpl.java

http://spatial-indexing.googlecode.com/ · Java · 26 lines · 20 code · 6 blank · 0 comment · 0 complexity · 2373ee238eb2fc1c2cd38e10230ae0d0 MD5 · raw file

  1. package file_parser;
  2. import java.io.FileInputStream;
  3. import org.apache.poi.hwpf.HWPFDocument;
  4. import org.apache.poi.hwpf.extractor.WordExtractor;
  5. import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  6. public class WORDParserImpl implements IFileParser {
  7. @Override
  8. public String parseFile(String fileName) {
  9. POIFSFileSystem filesystem = null;
  10. try{
  11. filesystem = new POIFSFileSystem(new FileInputStream(fileName));
  12. HWPFDocument document = new HWPFDocument(filesystem);
  13. WordExtractor extractor = new WordExtractor(document);
  14. return extractor.getText();
  15. } catch (Exception e){
  16. e.printStackTrace();
  17. }
  18. return null;
  19. }
  20. }