You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2009/08/17 17:49:50 UTC
svn commit: r805016 -
/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
Author: robbie
Date: Mon Aug 17 15:49:50 2009
New Revision: 805016
URL: http://svn.apache.org/viewvc?rev=805016&view=rev
Log:
QPID-2040: add a copy method to FileUtils that throws checked exceptions instead of wrapping as them runtime exceptions
Modified:
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
Modified: qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java?rev=805016&r1=805015&r2=805016&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java (original)
+++ qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java Mon Aug 17 15:49:50 2009
@@ -196,24 +196,7 @@
{
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();
+ copyCheckedEx(src, dst);
}
catch (IOException e)
{
@@ -221,6 +204,36 @@
}
}
+ /**
+ * Copies the specified source file to the specified destination file. If the destination file does not exist,
+ * it is created.
+ *
+ * @param src The source file name.
+ * @param dst The destination file name.
+ * @throws IOException
+ */
+ public static void copyCheckedEx(File src, File dst) throws IOException
+ {
+ 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();
+ }
+
/*
* Deletes a given file
*/
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org