ASF Bugzilla – Attachment 7426 Details for
Bug 21775
Non-MS Office Docs with Valid Header Signature
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Source Code to demonstrate ClassCastException on SummaryInformation.getWordCount() for .shw files
DocumentPropertyReader.java (text/plain), 1.46 KB, created by
Jacob Zwiers
on 2003-07-21 17:08:24 UTC
(
hide
)
Description:
Source Code to demonstrate ClassCastException on SummaryInformation.getWordCount() for .shw files
Filename:
MIME Type:
Creator:
Jacob Zwiers
Created:
2003-07-21 17:08:24 UTC
Size:
1.46 KB
patch
obsolete
>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() ); > } > } > > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 21775
:
7425
| 7426