Hi everybody

Is it possible to read recursively a directory and output file names
 (and/or content) in a streamList like the outputytpe paramater for the
JDBC component.

I had to process large directories with many file. Right now my route
recurse in all sub directories before starting to process each file. i
would like to find a solution to start processing file right after file
componant find it.

Here is a example :

public class FileScan {

    public static void main(String[] args) throws Exception {


        FileScan example = new FileScan();
        example.boot();
    }

    public void boot() throws Exception {
        // create a Main instance
        Main main = new Main();
        // enable hangup support so you can press ctrl + c to terminate the JVM
        main.enableHangupSupport();
        main.addRouteBuilder(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("file:C:\\Temp?noop=true&recursive=true&readLock=none")
                        .routeId("FileScanner").process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        System.out.println("Reading
"+exchange.getIn().getHeader("CamelFilePath"));
                    }
                });
            }
        });

        // run until you terminate the JVM
        System.out.println("Starting Camel. Use ctrl + c to terminate
the JVM.\n");
        main.run();
    }

}

Best regards

Pierre-Alban

Reply via email to