java - How to Use getViewableIterator in POI -


I am currently using POI to try to remove the text of the batch of Word documents and set it to me Which entries are in the document I am able to drag the document route and drag the first entry, but I want to be able to see all the entries. The getEntries () method provides this functionality, but I am in no disadvantage like using the getViewableIterator () to drag them out.

I have code-wise below:

  & lt; Cfset myFile = createObject ("java", "java.io.fileInputStream"). Init (fileInputPath) & gt; & Lt; Cfset fileSystem = CreateObject ("Java", "org.apache.poi.poifs.filesystem.POIFSFileSystem"). INIT (myFile) & gt; & Lt; Cfloop = "1" from = "# fileSystem.getRoot (). GetEntryCount () #" index = "I" & gt; & Lt; Cfset viewableIterator = fileSystem.getRoot (). GetEntries () Next (). GetViewableIterator () & gt; & Lt; Cfset nextEntry = fileSystem.getRoot (). GetEntries () Next ()> & Lt; Cfif viewable interface. HasNext () & gt; & Lt; Cfdump var = "#Next Entry.getShortDescription () #" & gt; & Lt; Cfset viewableIterator.remove () & gt; & Lt; / Cfif> & Lt; / Cfloop & gt;  

On the first loop, I am getting the first entry right now. However, I get the java.lang.IllegalStateException error as if remove () is executed. Obviously I am not using the method correctly, but I can not find an example of how it should be used properly. Any help will be very much appreciated.

I do not really understand your XML tags (usually I use Java as its normal form In, with curly braces and content), but usually a Java Iterator works like the following:

  while (iterator.hasNext ()) {x = iterator.next (); // What do you want to do with Element / X (/ * You want to remove X from the underlying list * /) iterator.remove (); } In practice, only very little is used, in such cases when you want to pass through a collection and remove all that you no longer need. If you are trying to read the failure or if you repeat it twice with two different walkers, then you may fail to remove it just next and next. 


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -