public class DocumentPropertyReader { private final static String PROPERTY_LOCATION = "\005SummaryInformation"; public static Integer getWordCount( File _file ) { POIFSReader r = new POIFSReader(); MyPOIFSReaderListener propReader = new MyPOIFSReaderListener(); Integer wordCount = null; r.registerListener(propReader, PROPERTY_LOCATION); try { // Given that this works, it appears as though // the reader blocks util it has // satisfied all of it's listeners. r.read(new FileInputStream(_file)); // Now that our listener has done it's thing, // we can get the word count from it. wordCount = propReader.wordCount; } catch ( IOException ioex ) { System.out.println("getWordCount(File): Could not obtain word cout for " + _file.getName() + ". Probably not an OLE2 Document. " + ioex.getMessage() ); } return wordCount; } static class MyPOIFSReaderListener implements POIFSReaderListener { Integer wordCount = null; public void processPOIFSReaderEvent(POIFSReaderEvent event) { SummaryInformation si = null; try { si = (SummaryInformation) PropertySetFactory.create(event.getStream()); } catch (Exception ex) { logger.info("processPOIFSReaderEvent(): Exception creating SummaryInformation \"" + event.getPath() + event.getName() + "\": " + ex); } if ( si != null ) { wordCount = new Integer( si.getWordCount() ); } } } }