@Test
public void test58616() throws IOException, GeneralSecurityException {
- POIFSFileSystem pfs = new POIFSFileSystem(new FileInputStream(XSSFTestDataSamples.getSampleFile("58616.xlsx")));
+ FileInputStream fis = new FileInputStream(XSSFTestDataSamples.getSampleFile("58616.xlsx"));
+ POIFSFileSystem pfs = new POIFSFileSystem(fis);
EncryptionInfo info = new EncryptionInfo(pfs);
Decryptor dec = Decryptor.getInstance(info);
//dec.verifyPassword(null);
dec.getDataStream(pfs);
+ pfs.close();
+ fis.close();
}
@Test
ByteArrayOutputStream bos = new ByteArrayOutputStream();
fs.writeFilesystem(bos);
-
+ fs.close();
+
nfs = new NPOIFSFileSystem(new ByteArrayInputStream(bos.toByteArray()));
infoActual = new EncryptionInfo(nfs.getRoot());
Decryptor decActual = Decryptor.getInstance(infoActual);
enc.confirmPassword("password");
OutputStream os = enc.getDataStream(fs);
pkg.save(os);
+ os.close();
pkg.revert();
// Save the resulting OLE2 document, and re-open it
ByteArrayOutputStream baos = new ByteArrayOutputStream();
fs.writeFilesystem(baos);
+ fs.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
NPOIFSFileSystem inpFS = new NPOIFSFileSystem(bais);
assertNotNull(inpPkg.getPackageProperties());
assertNotNull(inpPkg.getPackageProperties().getLanguageProperty());
assertNull(inpPkg.getPackageProperties().getLanguageProperty().getValue());
+
+ inpPkg.close();
+ inpFS.close();
}
@Test
assertTrue(b);
// do some strange things with it ;)
- XWPFDocument docx = new XWPFDocument(d.getDataStream(fs));
+ InputStream docIS = d.getDataStream(fs);
+ XWPFDocument docx = new XWPFDocument(docIS);
docx.getParagraphArray(0).insertNewRun(0).setText("POI was here! All your base are belong to us!");
docx.getParagraphArray(0).insertNewRun(1).addBreak();
Encryptor e = encInfo.getEncryptor();
e.confirmPassword("AYBABTU");
docx.write(e.getDataStream(fs));
+ docx.close();
+ docIS.close();
docx.close();
fs.close();
private final DirectoryEntry root;
// keys are DocumentDescriptors, values are byte[]s
- private final Map<DocumentDescriptor, byte[]> dataMap;
+ private final Map<DocumentDescriptor, byte[]> dataMap;
/**
* Constructor ReaderWriter
filesystem.writeFilesystem(ostream);
ostream.close();
+
+ filesystem.close();
}
}