/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package camelinaction;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class FileCopier {

    public static void main(String args[]) throws Exception {
        File inboxDirectory = new File("data/inbox");
        File outboxDirectory = new File("data/outbox");
        
        outboxDirectory.mkdir();
        
        File[] files = inboxDirectory.listFiles();
        for (File source : files) {
            File dest = new File(
                    outboxDirectory.getPath() 
                    + File.separator 
                    + source.getName()); 
            copyFile(source, dest);
        }
    }
    
    private static void copyFile(File source, File dest) 
        throws IOException {
        OutputStream out = new FileOutputStream(dest);
        byte[] buffer = new byte[(int) source.length()];
        FileInputStream in = new FileInputStream(source);
        in.read(buffer);
        try {
            out.write(buffer);
        } finally {
            out.close();      
            in.close();
        }
    }
}

@@ -1302,16 +1302,55 @@
 iles) %7B%0A
+            if (source.isFile()) %7B%0A    
         
@@ -1375,16 +1375,20 @@
 w File(%0A
+    
         
@@ -1446,16 +1446,20 @@
         
+ 
+   
 + File.s
@@ -1468,16 +1468,20 @@
 arator %0A
+    
         
@@ -1526,16 +1526,20 @@
         
+ 
+   
 copyFile
@@ -1550,24 +1550,38 @@
 rce, dest);%0A
+            %7D%0A
         %7D%0A  

fix plain java example in ch 1