summaryrefslogtreecommitdiff
path: root/qpid/java/qpid-test-utils
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/qpid-test-utils')
-rw-r--r--qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestFileUtils.java49
1 files changed, 27 insertions, 22 deletions
diff --git a/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestFileUtils.java b/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestFileUtils.java
index 26bbe151d2..00231039c3 100644
--- a/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestFileUtils.java
+++ b/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestFileUtils.java
@@ -121,33 +121,38 @@ public class TestFileUtils
File file = createTempFile(testcase, suffix);
if (content != null)
{
- FileOutputStream fos = null;
- try
- {
- fos = new FileOutputStream(file);
- fos.write(content.getBytes("UTF-8"));
- fos.flush();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Cannot add the content into temp file " + file.getAbsolutePath(), e);
- }
- finally
+ saveTextContentInFile(content, file);
+ }
+ return file;
+ }
+
+ public static void saveTextContentInFile(String content, File file)
+ {
+ FileOutputStream fos = null;
+ try
+ {
+ fos = new FileOutputStream(file);
+ fos.write(content.getBytes("UTF-8"));
+ fos.flush();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Cannot add the content into temp file " + file.getAbsolutePath(), e);
+ }
+ finally
+ {
+ if (fos != null)
{
- if (fos != null)
+ try
{
- try
- {
- fos.close();
- }
- catch (IOException e)
- {
- throw new RuntimeException("Cannot close output stream into temp file " + file.getAbsolutePath(), e);
- }
+ fos.close();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Cannot close output stream into temp file " + file.getAbsolutePath(), e);
}
}
}
- return file;
}
/**