Camel 文件路由不会从 Absolute Uri 复制文件
Camel file route does not copy file from Absolute Uri
这是我的代码
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=true
和 file:data/outbox
,同样可以正常工作。
您使用的是windows,路线应该是这样的
from("file:\C\Users\john\Desktop\inbox?noop=true")
.to("file:\C\Users\john\Desktop\outbox")
您应该在磁盘名称后使用冒号 - C:
from("file:C:/Users/john/Desktop/inbox?noop=true")
读这个:http://docs.oracle.com/javase/tutorial/essential/io/pathOps.html
花了一些时间弄清楚如何从 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();
}
这是我的代码
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=true
和 file:data/outbox
,同样可以正常工作。
您使用的是windows,路线应该是这样的
from("file:\C\Users\john\Desktop\inbox?noop=true")
.to("file:\C\Users\john\Desktop\outbox")
您应该在磁盘名称后使用冒号 - C:
from("file:C:/Users/john/Desktop/inbox?noop=true")
读这个:http://docs.oracle.com/javase/tutorial/essential/io/pathOps.html
花了一些时间弄清楚如何从 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();
}