diff --git a/poi-integration/src/test/java/org/apache/poi/stress/HPBFFileHandler.java b/poi-integration/src/test/java/org/apache/poi/stress/HPBFFileHandler.java index 5897803e74..a9e10430ac 100644 --- a/poi-integration/src/test/java/org/apache/poi/stress/HPBFFileHandler.java +++ b/poi-integration/src/test/java/org/apache/poi/stress/HPBFFileHandler.java @@ -45,22 +45,16 @@ public class HPBFFileHandler extends POIFSFileHandler { void test() throws Exception { File file = new File("test-data/publisher/SampleBrochure.pub"); - InputStream stream = new FileInputStream(file); - try { + try (InputStream stream = new FileInputStream(file)) { handleFile(stream, file.getPath()); - } finally { - stream.close(); } handleExtracting(file); - stream = new FileInputStream(file); - try { + try (InputStream stream = new FileInputStream(file)) { try (PublisherTextExtractor extractor = new PublisherTextExtractor(stream)) { assertNotNull(extractor.getText()); } - } finally { - stream.close(); } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java index a723fc2cc1..c3d44099de 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java @@ -23,6 +23,7 @@ import java.io.InputStream; import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream; import org.apache.poi.poifs.filesystem.DirectoryNode; +import org.apache.poi.poifs.filesystem.Entry; import org.apache.poi.util.IOUtils; /** @@ -57,7 +58,11 @@ public abstract class HPBFPart { DirectoryNode dir = baseDir; for(int i=0; i