summaryrefslogtreecommitdiff
path: root/qpid/java/common/src/main
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2008-10-08 10:52:57 +0000
committerMartin Ritchie <ritchiem@apache.org>2008-10-08 10:52:57 +0000
commit063b356109978a25197721cbb16c07a5c2efd338 (patch)
treeddad458f4bf6c1b5d49e9205eb2ad2c15e907c01 /qpid/java/common/src/main
parentf0029a075c06a1757fa1b508250d6c88546dfafc (diff)
downloadqpid-python-063b356109978a25197721cbb16c07a5c2efd338.tar.gz
QPID-1268 : Improved cleanup and fixed bug in FileUtils.readFileAsString() where it did not close the file.. hence the failures on windows machines in FileUtilsTest
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@702804 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/common/src/main')
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java36
1 files changed, 25 insertions, 11 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java b/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
index 883373ba35..3e13259ee3 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
@@ -46,16 +46,30 @@ public class FileUtils
{
BufferedInputStream is = null;
- try
- {
- is = new BufferedInputStream(new FileInputStream(filename));
- }
- catch (FileNotFoundException e)
- {
- throw new RuntimeException(e);
- }
+ try{
+ try
+ {
+ is = new BufferedInputStream(new FileInputStream(filename));
+ }
+ catch (FileNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
- return readStreamAsString(is);
+ return readStreamAsString(is);
+ }finally {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
}
/**
@@ -230,14 +244,14 @@ public class FileUtils
*/
public static boolean delete(File file, boolean recursive)
{
- boolean success=true;
+ boolean success = true;
if (file.isDirectory())
{
if (recursive)
{
for (File subFile : file.listFiles())
- {
+ {
success = delete(subFile, true) & success ;
}