Saturday, May 25, 2013

How to upload file on ftp using Apache Camel

 //This example is represent how to upload file to FTP using Apache Camel
 
 import org.apache.camel.builder.RouteBuilder;  
 import org.apache.camel.main.Main;  
 public class Myownclass {  
      public static void main(String[] args) {  
           try {  
                Main main = new Main();  
                main.addRouteBuilder(new RouteBuilder() {  
                     @Override  
                     public void configure() throws Exception {  
                          // TODO Auto-generated method stub  
                          errorHandler(deadLetterChannel("mock:error"));  
                          from("file:C:/Users/cuboidology8/Downloads?noop=true").to("ftp://cuboidology8@127.1.2.3:21/src?password=cuboidology8")  
                                    .log("Downloaded file ${file:name} complete.");  
                     }  
                });  
                main.enableHangupSupport();  
                main.run();  
                // create the camel context:  
           } catch (Exception e) {  
                // this is an example -> don't handle exceptions:  
                e.printStackTrace();  
           }  
      }  
 }  

No comments:

Post a Comment