Author: fanningpj
Date: Wed Dec 20 11:47:52 2017
New Revision: 1818781

URL: http://svn.apache.org/viewvc?rev=1818781&view=rev
Log:
use try with resources

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1818781&r1=1818780&r2=1818781&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java 
Wed Dec 20 11:47:52 2017
@@ -544,9 +544,9 @@ public class XSSFWorkbook extends POIXML
     public int addPicture(InputStream is, int format) throws IOException {
         int imageNumber = getAllPictures().size() + 1;
         XSSFPictureData img = 
createRelationship(XSSFPictureData.RELATIONS[format], 
XSSFFactory.getInstance(), imageNumber, true).getDocumentPart();
-        OutputStream out = img.getPackagePart().getOutputStream();
-        IOUtils.copy(is, out);
-        out.close();
+        try (OutputStream out = img.getPackagePart().getOutputStream()) {
+            IOUtils.copy(is, out);
+        }
         pictures.add(img);
         return imageNumber - 1;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org
For additional commands, e-mail: commits-h...@poi.apache.org

Reply via email to