poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fannin...@apache.org
Subject svn commit: r1818781 - /poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
Date Wed, 20 Dec 2017 11:47:52 GMT
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-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message