You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2015/08/27 06:43:23 UTC

svn commit: r1698066 - /httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java

Author: ggregory
Date: Thu Aug 27 04:43:22 2015
New Revision: 1698066

URL: http://svn.apache.org/r1698066
Log:
Use try-with-resources.

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java?rev=1698066&r1=1698065&r2=1698066&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java Thu Aug 27 04:43:22 2015
@@ -168,16 +168,13 @@ public class NFileEntity extends Abstrac
     @Override
     public void writeTo(final OutputStream outstream) throws IOException {
         Args.notNull(outstream, "Output stream");
-        final InputStream instream = new FileInputStream(this.file);
-        try {
+        try (final InputStream instream = new FileInputStream(this.file)) {
             final byte[] tmp = new byte[4096];
             int l;
             while ((l = instream.read(tmp)) != -1) {
                 outstream.write(tmp, 0, l);
             }
             outstream.flush();
-        } finally {
-            instream.close();
         }
     }