Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Accumulo >> mail # dev >> Do Outer Input Streams Need to be Closed?


+
David Medinets 2012-11-17, 05:04
Copy link to this message
-
Re: Do Outer Input Streams Need to be Closed?
Not necessary, BufferedReader.close() simply closes the encasing input
stream and nulls out the 2 internal objects for it (the input and the
buffer).
On Sat, Nov 17, 2012 at 12:04 AM, David Medinets
<[EMAIL PROTECTED]>wrote:

> I've seen a lot of Java code that looks like this example from
> org.apache.accumulo.core.client.admin.TableOperationsImpl. Does the
> BufferedReader need to be closed or it is automatically closed when
> the ZipInputStream is closed?
>
>     ZipInputStream zis = new ZipInputStream(fs.open(path));
>     try {
>       ZipEntry zipEntry;
>       while ((zipEntry = zis.getNextEntry()) != null) {
>         if (zipEntry.getName().equals(Constants.EXPORT_TABLE_CONFIG_FILE))
> {
>           BufferedReader in = new BufferedReader(new
> InputStreamReader(zis));
>           String line;
>           while ((line = in.readLine()) != null) {
>             String sa[] = line.split("=", 2);
>             props.put(sa[0], sa[1]);
>           }
>
>           break;
>         }
>       }
>     } finally {
>       zis.close();
>     }
>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB