0
使用下面的代码创建骆驼路线,但是当在源中创建文件时,测试中不会出现任何影响。为什么?如何使用Apache Camel将文件插入输入文件夹后立即将文件移动到输出文件夹中?
public class DriverMain {
public static void main(String[] a) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("file://source").to("file://test");
}
});
context.start();
String path = System.getProperty("user.dir")+"\\source";
File dir = new File(path);
File file = new File(path+"\\testfile.txt");
file.createNewFile();
}
}
您还应该在最后停止上下文。添加一个context.stop()作为最后一行。另外,from()和to()从相对文件夹中读取。您确定您的应用在user.dir/source下运行? –