hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1698066 - /httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
Date Thu, 27 Aug 2015 04:43:23 GMT
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();
         }
     }
 



Mime
View raw message