Ulf Dittmer wrote:Doesn't FileItem contain a method that suggests itself?
Lester Burnham wrote:I think you missed what I was trying to convey. The problem has nothing to do with handling a Word document, and also nothing to do with the POI library.
The problem is that the code is using an array index that is invalid. You still haven't told us in which line of code the exception happens, so I'm assuming it's in "e.textAreas[tabcount]". Apparently tabcount has a value of 4, while textAreas has a size of less than 5. That's where you should begin investigating.
On the other hand, if the exception happens in some other line of code, then it's high time you told us which line that is (and also posted the full stack trace of the exception).
Lester Burnham wrote:The error is not occurring in the POI code, it's in the Swing code, so it's not surprising that there are no problems opening the file in Word. You didn't say in which line the exception happens, but it's probably in "e.textAreas[tabcount]", since that's the only array being used. Apparently, the textAreas array does not have 5 elements, so trying to access element #4 won't work. (Remember that arrays are 0-based in Java, so at index 4 is the 5th element).