close streams if an exception is throw
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751983 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
909c07f37f
commit
ca22a79e01
@ -63,9 +63,13 @@ public class POIFSDump {
|
||||
|
||||
System.out.println("Dumping " + filename);
|
||||
FileInputStream is = new FileInputStream(filename);
|
||||
NPOIFSFileSystem fs = new NPOIFSFileSystem(is);
|
||||
NPOIFSFileSystem fs;
|
||||
try {
|
||||
fs = new NPOIFSFileSystem(is);
|
||||
} finally {
|
||||
is.close();
|
||||
|
||||
}
|
||||
try {
|
||||
DirectoryEntry root = fs.getRoot();
|
||||
File file = new File(new File(filename).getName(), root.getName());
|
||||
if (!file.exists() && !file.mkdirs()) {
|
||||
@ -87,10 +91,11 @@ public class POIFSDump {
|
||||
dump(fs, startBlock, "mini-stream", file);
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
fs.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void dump(DirectoryEntry root, File parent) throws IOException {
|
||||
for(Iterator<Entry> it = root.getEntries(); it.hasNext();){
|
||||
|
Loading…
Reference in New Issue
Block a user