Hi, On Tue, Sep 29, 2009 at 5:55 PM, <a...@swmc.com> wrote: > I don't see anything which jumps out at me here other than you're closing > the document in 3 places where it's not needed (although that won't hurt > anything). Your outer try seems unnecessary, and I can't see what > isFailedFile would be set to when this code is called (or even where it is > defined for that matter). The "finally" should always close the file > (which means it'll always already be closed by the time you get to the > catch statement, return statement, or at the end of the function).
Exactly. As a general rule, the following pattern is guaranteed to always close a resource: SomeResource resource = createSomeResource(); try { ....; } finally { resource.close(); } For PDDocument the pattern is: PDDocument document = PDDocument.load(...); try { ...; } finally { document.close(); } BR, Jukka Zitting