*/
public void write(File newFile) throws IOException {
POIFSFileSystem fs = POIFSFileSystem.create(newFile);
- write(fs);
- fs.writeFilesystem();
+ try {
+ write(fs);
+ fs.writeFilesystem();
+ } finally {
+ fs.close();
+ }
}
/**
* Write out, with any properties changes, but nothing else
*/
public void write(OutputStream out) throws IOException {
NPOIFSFileSystem fs = new NPOIFSFileSystem();
- write(fs);
- fs.writeFilesystem(out);
+ try {
+ write(fs);
+ fs.writeFilesystem(out);
+ } finally {
+ fs.close();
+ }
}
private void write(NPOIFSFileSystem fs) throws IOException {
@Override
public void write(OutputStream out) throws IOException {
// Write out, but only the common streams
- write(out,false);
+ write(out, false);
}
/**
* Writes out the slideshow file the is represented by an instance
* the passed in OutputStream
*/
public void write(OutputStream out, boolean preserveNodes) throws IOException {
+ // Get a new FileSystem to write into
+ POIFSFileSystem outFS = new POIFSFileSystem();
+
+ try {
+ // Write into the new FileSystem
+ write(outFS, preserveNodes);
+
+ // Send the POIFSFileSystem object out to the underlying stream
+ outFS.writeFilesystem(out);
+ } finally {
+ outFS.close();
+ }
+ }
+ private void write(POIFSFileSystem outFS, boolean preserveNodes) throws IOException {
// read properties and pictures, with old encryption settings where appropriate
- if(_pictures == null) {
+ if (_pictures == null) {
readPictures();
}
getDocumentSummaryInformation();
HSLFSlideShowEncrypted encryptedSS = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom());
_records = encryptedSS.updateEncryptionRecord(_records);
- // Get a new Filesystem to write into
- POIFSFileSystem outFS = new POIFSFileSystem();
-
// The list of entries we've written out
List<String> writtenEntries = new ArrayList<String>(1);
}
// If requested, write out any other streams we spot
- if(preserveNodes) {
+ if (preserveNodes) {
EntryUtils.copyNodes(directory.getFileSystem(), outFS, writtenEntries);
}
-
- // Send the POIFSFileSystem object out to the underlying stream
- outFS.writeFilesystem(out);
- outFS.close();
}
/**