You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2014/07/15 19:58:50 UTC

svn commit: r1610781 - /commons/proper/csv/trunk/src/site/xdoc/user-guide.xml

Author: britter
Date: Tue Jul 15 17:58:49 2014
New Revision: 1610781

URL: http://svn.apache.org/r1610781
Log:
Use try-with-resource in examples

Modified:
    commons/proper/csv/trunk/src/site/xdoc/user-guide.xml

Modified: commons/proper/csv/trunk/src/site/xdoc/user-guide.xml
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/site/xdoc/user-guide.xml?rev=1610781&r1=1610780&r2=1610781&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/site/xdoc/user-guide.xml (original)
+++ commons/proper/csv/trunk/src/site/xdoc/user-guide.xml Tue Jul 15 17:58:49 2014
@@ -39,16 +39,14 @@ for (CSVRecord record : records) {
     class from <a href="https://commons.apache.org/proper/commons-io/">Apache Commons IO</a> for example: 
   </p>
   <source>final URL url = ...;
-final Reader reader = new InputStreamReader(new BOMInputStream(url.openStream()), "UTF-8");
-final CSVParser parser = new CSVParser(reader, CSVFormat.EXCEL.withHeader());
-try {
+try (
+    final Reader reader = new InputStreamReader(new BOMInputStream(url.openStream()), "UTF-8");
+    final CSVParser parser = new CSVParser(reader, CSVFormat.EXCEL.withHeader());
+) {
     for (final CSVRecord record : parser) {
         final String string = record.get("SomeColumn");
         ...
     }
-} finally {
-    parser.close();
-    reader.close();
 }</source>
 </section>
 <!-- ================================================== -->