I'm currently using POI to attempt to extract text out of a batch of Word documents and I need to be able to determine what entries a document contains. I've been able to get as far as pulling the document root and pulling the first entry but I want to be able to view all entries. the getEntries() method seems to provide this functionality but I'm at a loss as to how to use getViewableIterator() to pull them out. Below is what I have code-wise:
<cfset myFile = createObject("java", "java.io.FileInputStream").init(fileInputPath)>
<cfset fileSystem = CreateObject( "java", "org.apache.poi.poifs.filesystem.POIFSFileSystem" ).Init(myFile)>
<cfloop from="1" to="#fileSystem.getRoot().getEntryCount()#" index="i">
<cfset viewableIterator = fileSystem.getRoot().getEntries().next().getViewableIterator()>
<cfset nextEntry = fileSystem.getRoot().getEntries().next()>
<cfif viewableIterator.hasNext()>
<cfdump var="#nextEntry.getShortDescription()#">
<cfset viewableIterator.remove()>
</cfif>
</cfloop>
On the first loop, I'm able to get the first entry just fine. However, I get an java.lang.IllegalStateException error as soon as remove() is executed. Obviously I'm not using the remove() method correctly but I haven't been able to find any examples of how this should be properly used. Any help would be greatly appreciated.
Thanks, --Anne