Author: onealj
Date: Mon Sep 18 00:25:54 2017
New Revision: 1808664

URL: http://svn.apache.org/viewvc?rev=1808664&view=rev
Log:
update Jython example to use closing context manager

Modified:
    poi/site/publish/poi-jvm-languages.html
    poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml

Modified: poi/site/publish/poi-jvm-languages.html
URL: 
http://svn.apache.org/viewvc/poi/site/publish/poi-jvm-languages.html?rev=1808664&r1=1808663&r2=1808664&view=diff
==============================================================================
--- poi/site/publish/poi-jvm-languages.html (original)
+++ poi/site/publish/poi-jvm-languages.html Mon Sep 18 00:25:54 2017
@@ -397,6 +397,7 @@ if (VERSION > 3) {
         sys.path.append('/path/to/%s-3.14-20160307.jar')
         
     from java.io import File, FileOutputStream
+    from contextlib import closing
 
     # Import the POI classes
     from org.apache.poi.ss.usermodel import <a 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/WorkbookFactory.html";>WorkbookFactory</a>,
 <a 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DataFormatter.html";>DataFormatter</a>
@@ -419,8 +420,8 @@ if (VERSION > 3) {
     cell.cellValue = 'The answer to life, the universe, and everything'
 
     # Save and close the workbook
-    fos = FileOutputStream('SampleSS-updated.xlsx')
-    wb.write(fos)
+    with closing(FileOutputStream('SampleSS-updated.xlsx')) as fos:
+        wb.write(fos)
     wb.close()
       </pre>
       

Modified: poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml
URL: 
http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml?rev=1808664&r1=1808663&r2=1808664&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml (original)
+++ poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml Mon Sep 18 
00:25:54 2017
@@ -112,6 +112,7 @@
         sys.path.append('/path/to/%s-3.14-20160307.jar')
         
     from java.io import File, FileOutputStream
+    from contextlib import closing
 
     # Import the POI classes
     from org.apache.poi.ss.usermodel import <link 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/WorkbookFactory.html";>WorkbookFactory</link>,
 <link 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DataFormatter.html";>DataFormatter</link>
@@ -134,8 +135,8 @@
     cell.cellValue = 'The answer to life, the universe, and everything'
 
     # Save and close the workbook
-    fos = FileOutputStream('SampleSS-updated.xlsx')
-    wb.write(fos)
+    with closing(FileOutputStream('SampleSS-updated.xlsx')) as fos:
+        wb.write(fos)
     wb.close()
       </source>
       <p>There are several websites that have examples of using Apache POI in 
Jython projects:



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to