Camel文件路由不会从Absolute Uri复制文件

时间:2015-03-26 13:57:12

标签: java apache-camel

这是我的代码

context.addRoutes(new RouteBuilder() {
    public void configure() {
        from("file:/C/Users/john/Desktop/inbox?noop=true")
        .to("file:/C/Users/john/Desktop/outbox")
        .process(new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                System.out.println("test " + exchange.toString());
            }
        });
    }
});

context.start();

如果我使用file://data/inbox?noop=truefile:data/outbox,则同样正常。

3 个答案:

答案 0 :(得分:1)

你应该在磁盘名称之后使用冒号 - C:

from("file:C:/Users/john/Desktop/inbox?noop=true")

请阅读:http://docs.oracle.com/javase/tutorial/essential/io/pathOps.html

答案 1 :(得分:0)

您正在使用窗户,路线应该是这样的

from("file:\\C\\Users\\john\\Desktop\\inbox?noop=true")
                        .to("file:\\C\\Users\\john\\Desktop\\outbox")

答案 2 :(得分:0)

花了一些时间来弄清楚如何从Windows上的磁盘根目录复制文件,

public static final String FROM = "file:D:?noop=true";
public static final String TO = "file:D:/camel/";

public static void main(String... args) throws Exception {

    CamelContext ctx = new DefaultCamelContext();

    ctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from(FROM).to(TO).end();
        }
    });
    ctx.start();
    Thread.sleep(5000);
    ctx.stop();
}