[OFBiz] SVN: r7217 - trunk/base/src/base/org/ofbiz/base/util

jaz@svn.ofbiz.org jaz at svn.ofbiz.org
Thu Apr 6 13:55:23 CDT 2006


Author: jaz
Date: 2006-04-06 13:55:22 -0500 (Thu, 06 Apr 2006)
New Revision: 7217

Modified:
   trunk/base/src/base/org/ofbiz/base/util/FileUtil.java
Log:
fixed the method to close the reader


Modified: trunk/base/src/base/org/ofbiz/base/util/FileUtil.java
===================================================================
--- trunk/base/src/base/org/ofbiz/base/util/FileUtil.java	2006-04-06 18:53:14 UTC (rev 7216)
+++ trunk/base/src/base/org/ofbiz/base/util/FileUtil.java	2006-04-06 18:55:22 UTC (rev 7217)
@@ -107,15 +107,30 @@
         }
 
         StringBuffer buf = new StringBuffer();
-        BufferedReader in = new BufferedReader(new FileReader(file));
-        String str;
-        while ((str = in.readLine()) != null) {
-            buf.append(str);
-            if (newline) {
-                buf.append(System.getProperty("line.separator"));
+        BufferedReader in = null;
+        try {
+            in = new BufferedReader(new FileReader(file));
+
+            String str;
+            while ((str = in.readLine()) != null) {
+                buf.append(str);
+                if (newline) {
+                    buf.append(System.getProperty("line.separator"));
+                }
             }
+        } catch (IOException e) {
+            Debug.logError(e, module);
+            throw e;
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    Debug.logError(e, module);
+                }
+            }
         }
-
+        
         return buf;
     }
 }



More information about the Svn mailing list