summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2007-04-04 15:19:38 +0000
committerRobert Greig <rgreig@apache.org>2007-04-04 15:19:38 +0000
commited595b155f4382a1401d6b47ab316e7e5b223243 (patch)
treec5968b99cb9da2c86ba4ddd2927adca81189e469 /java
parent373ed42d849c7409d47ba1f4216b235dc2e233f4 (diff)
downloadqpid-python-ed595b155f4382a1401d6b47ab316e7e5b223243.tar.gz
Added simeple file copy function.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@525533 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/common/src/main/java/org/apache/qpid/util/FileUtils.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/util/FileUtils.java b/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
index ba79a6e8d4..3c8d3f916b 100644
--- a/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
+++ b/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
@@ -158,4 +158,40 @@ public class FileUtils
return is;
}
+
+ /**
+ * Copies the specified source file to the specified destintaion file. If the destinationst file does not exist,
+ * it is created.
+ *
+ * @param src The source file name.
+ * @param dst The destination file name.
+ */
+ public static void copy(File src, File dst)
+ {
+ try
+ {
+ InputStream in = new FileInputStream(src);
+ if (!dst.exists())
+ {
+ dst.createNewFile();
+ }
+
+ OutputStream out = new FileOutputStream(dst);
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0)
+ {
+ out.write(buf, 0, len);
+ }
+
+ in.close();
+ out.close();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
}