Author: lhein
Date: Mon Jul 20 11:48:56 2009
New Revision: 795776

URL: http://svn.apache.org/viewvc?rev=795776&view=rev
Log:
all copy activities now use the fastCopy method

Modified:
    
servicemix/utils/trunk/src/main/java/org/apache/servicemix/util/FileUtil.java

Modified: 
servicemix/utils/trunk/src/main/java/org/apache/servicemix/util/FileUtil.java
URL: 
http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/util/FileUtil.java?rev=795776&r1=795775&r2=795776&view=diff
==============================================================================
--- 
servicemix/utils/trunk/src/main/java/org/apache/servicemix/util/FileUtil.java 
(original)
+++ 
servicemix/utils/trunk/src/main/java/org/apache/servicemix/util/FileUtil.java 
Mon Jul 20 11:48:56 2009
@@ -41,12 +41,6 @@
  */
 public final class FileUtil {
 
-       /**
-        * Buffer size used when copying the content of an input stream to an 
output
-        * stream.
-        */
-       private static final int DEFAULT_BUFFER_SIZE = 4096;
-
        private FileUtil() {
        }
 
@@ -59,9 +53,11 @@
         */
        public static void moveFile(File src, File targetDirectory)
                        throws IOException {
-               if (!src.renameTo(new File(targetDirectory, src.getName()))) {
-                       throw new IOException("Failed to move " + src + " to "
-                                       + targetDirectory);
+               if (src == null || !src.exists() || !src.isFile() ||
+                   targetDirectory == null || !targetDirectory.exists() || 
!targetDirectory.isDirectory() ||
+                   !src.renameTo(new File(targetDirectory, src.getName()))) {
+                       // unable to move the file
+                       throw new IOException("Failed to move " + src + " to " 
+ targetDirectory);
                }
        }
 
@@ -119,14 +115,8 @@
         */
        public static void copyInputStream(InputStream in, OutputStream out)
                        throws IOException {
-               byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
-               int len = in.read(buffer);
-               while (len >= 0) {
-                       out.write(buffer, 0, len);
-                       len = in.read(buffer);
-               }
-               in.close();
-               out.close();
+               // simply use the fastCopy method
+               fastCopy(in, out);
        }
 
        /**
@@ -182,8 +172,7 @@
                if (!targetDir.exists()) {
                        targetDir.mkdirs();
                }
-               InputStream in = new BufferedInputStream(url.openStream(),
-                               DEFAULT_BUFFER_SIZE);
+               InputStream in = new BufferedInputStream(url.openStream());
                // make sure we get the actual file
                File zip = File.createTempFile("arc", ".zip", targetDir);
                OutputStream out = new BufferedOutputStream(new 
FileOutputStream(zip));


Reply via email to