diff options
author | Dominik Stadler <centic@apache.org> | 2015-03-14 13:18:43 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2015-03-14 13:18:43 +0000 |
commit | 2f8c89683fc573ce09c1f8384d2642b69ca35756 (patch) | |
tree | 20917f35922348bac8d59dfa01b94ba274166649 /src/scratchpad | |
parent | 2e47191ba760724592ac7dd14169f4438e1e7e31 (diff) | |
download | poi-2f8c89683fc573ce09c1f8384d2642b69ca35756.tar.gz poi-2f8c89683fc573ce09c1f8384d2642b69ca35756.zip |
Remove some findbugs warnings about missing close of streams, use existing IOUtils.copy() to copy from one stream to another
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1666683 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad')
-rw-r--r-- | src/scratchpad/src/org/apache/poi/hmef/extractor/HMEFContentsExtractor.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hmef/extractor/HMEFContentsExtractor.java b/src/scratchpad/src/org/apache/poi/hmef/extractor/HMEFContentsExtractor.java index 332a496c6e..f591d5a4d7 100644 --- a/src/scratchpad/src/org/apache/poi/hmef/extractor/HMEFContentsExtractor.java +++ b/src/scratchpad/src/org/apache/poi/hmef/extractor/HMEFContentsExtractor.java @@ -22,6 +22,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import org.apache.poi.hmef.Attachment; import org.apache.poi.hmef.HMEFMessage; @@ -70,13 +71,14 @@ public final class HMEFContentsExtractor { * Extracts the RTF message body to the supplied file */ public void extractMessageBody(File dest) throws IOException { - FileOutputStream fout = new FileOutputStream(dest); - - MAPIRtfAttribute body = (MAPIRtfAttribute) - message.getMessageMAPIAttribute(MAPIProperty.RTF_COMPRESSED); - fout.write(body.getData()); - - fout.close(); + OutputStream fout = new FileOutputStream(dest); + try { + MAPIRtfAttribute body = (MAPIRtfAttribute) + message.getMessageMAPIAttribute(MAPIProperty.RTF_COMPRESSED); + fout.write(body.getData()); + } finally { + fout.close(); + } } /** @@ -101,9 +103,12 @@ public final class HMEFContentsExtractor { // Save it File file = new File(dir, filename); - FileOutputStream fout = new FileOutputStream(file); - fout.write( att.getContents() ); - fout.close(); + OutputStream fout = new FileOutputStream(file); + try { + fout.write( att.getContents() ); + } finally { + fout.close(); + } } } } |