[pal-cvs 2371] [103] close input stream

svnno****@sourc***** svnno****@sourc*****
2007年 5月 11日 (金) 18:14:43 JST


Revision: 103
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=103
Author:   shinsuke
Date:     2007-05-11 18:14:43 +0900 (Fri, 11 May 2007)

Log Message:
-----------
close input stream

Modified Paths:
--------------
    pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/servlet/FileviewServlet.java


-------------- next part --------------
Modified: pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/servlet/FileviewServlet.java
===================================================================
--- pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/servlet/FileviewServlet.java	2007-05-11 09:14:05 UTC (rev 102)
+++ pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/servlet/FileviewServlet.java	2007-05-11 09:14:43 UTC (rev 103)
@@ -18,6 +18,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -80,8 +81,23 @@
                 mimeType = DownloadUtil.OCTET_STREAM;
             }
             // store
-            DownloadUtil.writeResponse(req, resp, mimeType, name,
-                    new FileInputStream(targetFile));
+            InputStream is = null;
+            try
+            {
+                is = new FileInputStream(targetFile);
+                DownloadUtil.writeResponse(req, resp, mimeType, name, is);
+            }
+            catch (IOException e)
+            {
+                throw e;
+            }
+            finally
+            {
+                if (is != null)
+                {
+                    is.close();
+                }
+            }
         }
         else
         {


pal-cvs メーリングリストの案内