2016-04-05 63 views
1
import org.apache.camel.CamelContext; 
import org.apache.camel.builder.RouteBuilder; 
import org.apache.camel.impl.DefaultCamelContext; 

public class ReadFileExample { 
public static void main(String [] args) throws Exception{ 
    System.out.println("trying to copy file"); 
    CamelContext ctx = new DefaultCamelContext(); 
    RouteBuilder route = new RouteBuilder() { 
     @Override 
     public void configure() throws Exception { 
      from("file://Users/aranja2/Documents/in/?fileName=sample.txt&charset=utf-8") 
      .to("file://Users/aranja2/Documents/out/?fileName=sample.txt&charset=utf-8"); 
     } 
    }; 
    ctx.addRoutes(route); 
    ctx.start(); 
    // Maybe sleep a little here 
    // Thread.sleep(4000); 
    ctx.stop(); 
} 
} 

我正在使用駱駝來複制文件,但它不會發生。我正在使用mac。拋出的消息是如何使用apache駱駝來複制文件

[主要] INFO org.apache.camel.impl.DefaultCamelContext - Apache的駱駝 2.16.2(CamelContext:駱駝-1)起始[主要] INFO org.apache.camel.management .ManagedManagementStrategy - JMX啓用 [主要] INFO org.apache.camel.impl.converter.DefaultTypeConverter - 加載183個的類型轉換器[主要] INFO org.apache.camel.impl.DefaultRuntimeEndpointRegistry - 運行時 端點註冊表是在擴展模式收集使用統計 所有傳入和傳出端點(緩存限制:1000)[main] INFO org.apache.camel.impl.DefaultCamelContext - AllowUseOriginalMessage is 已啓用。如果不需要訪問原始消息,則建議使用其 關閉此選項,因爲它可能會提高性能。 [main] INFO org.apache.camel.impl.DefaultCamelContext - StreamCaching 未使用。如果使用流,那麼推薦使用流 緩存。查看更多細節在 http://camel.apache.org/stream-caching.html [主要] INFO org.apache.camel.component.file.FileEndpoint - 端點被配置 與NOOP =爲冪等真以便迫使端點以及[主要] INFO org.apache.camel。 component.file.FileEndpoint - 使用默認 基於內存的冪等存儲庫,其最大大小爲:cache [1000] [main] INFO org.apache.camel.impl.DefaultCamelContext - Route:route1 started and consume from: Endpoint [file://用戶/ aranja2/Documents/in /?noop = true] [main]信息 org.apache.camel.impl.DefaultCamelContext - 共計1條路線,其中1 已啓動。 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2(CamelContext:camel-1)在0.344秒內啓動 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16 2(CamelContext:camel-1)正在關閉[main] INFO org.apache.camel.impl.DefaultShutdownStrategy - 開始優雅 關閉1路由(超時300秒)[Camel(camel-1)thread#1 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Route:route1 shutdown complete,耗時: Endpoint [file:// Users/aranja2/Documents/in /?noop = true] [main] INFO org .apache.camel.impl.DefaultShutdownStrategy - 在0秒內完成1 路由的優雅關閉[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2 (CamelContext:camel-1)正常運行時間0.359秒[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2 (CamelContext :camel-1)在0.007秒內關機

回答

0

您確定您到達//Users/aranja2/Documents/in/?fileName=sample.txt目錄嗎?你潰敗似乎沒問題。我附加了一個示例項目,其中包含從一個目錄複製到另一個目錄的路徑。這個詭計使用相同的參數fileName作爲你的。您可以運行它只是它MVN駱駝:運行

https://drive.google.com/file/d/0B9AooXd3hwFyWjZ4aEFRc0Znam8/view?usp=sharing

乾杯!

+0

對不起,鏈接指向我自己的驅動器 –