Java linux上的ApacheCamel文件IO

Java linux上的ApacheCamel文件IO,java,linux,apache-camel,Java,Linux,Apache Camel,我一直在尝试使用ApacheCamel设置一个简单的程序来读取一个文件并写入一个单独的文件,在谷歌搜索如何读取和阅读文档后,我想到了以下几点 public static void main(String[] argv) { CamelContext context = new DefaultCamelContext(); RouteBuilder route = new RouteBuilder() { @Override public void

我一直在尝试使用ApacheCamel设置一个简单的程序来读取一个文件并写入一个单独的文件,在谷歌搜索如何读取和阅读文档后,我想到了以下几点

public static void main(String[] argv) {
    CamelContext context = new DefaultCamelContext();
    RouteBuilder route = new RouteBuilder() {
        @Override
        public void configure() throws Exception {
             from("file:/home/user/?fileName=temp.txt&charset=UTF-8&noop=true")
             .to("/home/user/?fileName=tempOut.txt&charset=UTF-8");
        }
    }

    context.addRoutes(route);
    context.start();
    context.stop();
}
控制台输出如下

[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.11.1 (CamelContext: camel-1) is starting
[main] INFO org.apache.camel.management.ManagementStrategyFactory - JMX enabled.
[main] INFO org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 172 type converters
[main] INFO org.apache.camel.component.file.FileEndpoint - Endpoint is configured with noop=true so forcing endpoint to be idempotent as well
[main] INFO org.apache.camel.component.file.FileEndpoint - Using default memory based idempotent repository with cache max size: 1000
[main] INFO org.apache.camel.impl.DefaultCamelContext - Route: route1 started and consuming from: Endpoint[file:///home/justin/?charset=utf-8&fileName=temp1.txt&noop=true]
[main] INFO org.apache.camel.management.DefaultManagementLifecycleStrategy - Load performance statistics enabled.
[main] INFO org.apache.camel.impl.DefaultCamelContext - Total 1 routes, of which 1 is started.
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.11.1 (CamelContext: camel-1) started in 0.680 seconds
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.11.1 (CamelContext: camel-1) is shutting down
[main] INFO org.apache.camel.impl.DefaultShutdownStrategy - Starting to graceful shutdown 1 routes (timeout 300 seconds)
[Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Route: route1 shutdown complete, was consuming from: Endpoint[file:///home/justin/?charset=utf-8&fileName=temp1.txt&noop=true]
[main] INFO org.apache.camel.impl.DefaultShutdownStrategy - Graceful shutdown of 1 routes completed in 0 seconds
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.11.1 (CamelContext: camel-1) uptime 0.759 seconds
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.11.1 (CamelContext: camel-1) is shutdown in 0.032 seconds
然而,我没有得到任何结果tempOut.txt,至少在我的磁盘上对我来说是有意义的。我的问题是为什么会这样?我还注意到,在控制台的输出中,它说…consuming from:Endpoint[file:///home/... 由于我的文件路径中没有多余的/,它们从哪里来?

尝试从类中删除context.stop

启动Camel后,您会立即关闭它。因此,文件使用者扫描目录和处理文件的机会很小

对于斜杠:file://是文件URL的开头,就像http://。文件路径也以/开头,因为它是绝对的。因此,有三个斜杠