You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2007/04/04 17:19:38 UTC
svn commit: r525533 -
/incubator/qpid/branches/M2/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
Author: rgreig
Date: Wed Apr 4 08:19:38 2007
New Revision: 525533
URL: http://svn.apache.org/viewvc?view=rev&rev=525533
Log:
Added simeple file copy function.
Modified:
incubator/qpid/branches/M2/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
Modified: incubator/qpid/branches/M2/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/common/src/main/java/org/apache/qpid/util/FileUtils.java?view=diff&rev=525533&r1=525532&r2=525533
==============================================================================
--- incubator/qpid/branches/M2/java/common/src/main/java/org/apache/qpid/util/FileUtils.java (original)
+++ incubator/qpid/branches/M2/java/common/src/main/java/org/apache/qpid/util/FileUtils.java Wed Apr 4 08:19:38 2007
@@ -158,4 +158,40 @@
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);
+ }
+ }
}