by BehindJava

How to Transfer a file using Apache Camel file component in Spring Boot

Home » springboot » How to Transfer a file using Apache Camel file component in Spring Boot

In this tutorial, We will learn about using the Apache Camel file component to transfer a file using spring boot.

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

public class FileRouter extends RouteBuilder {

	public void configure() throws Exception {

Create the above class and run as spring boot application. After successful running of the application in the console you can see the below output in the console and files folder is created automatically by the camel framework.

 Tomcat started on port(s): 8080 (http) with context path ''
: Routes startup (total:1 started:1)
:     Started route2 (file://files/input)
: Apache Camel 3.14.0 (camel-2) started in 45ms (build:5ms init:37ms start:3ms)
: Started CamelMsAApplication in 1.112 seconds (JVM running for 144.401)

Refresh the project in the package explorer and you can see a new folder called files with input as the sub folder as stated in the above output.

In my case, I have these .exe files in my downloads I have copied all the files and pasted it in the input sub folder under files folder that is created by the spring boot application.

When you do so the pasted files are automatically moved into the newly created folder called output. But nothing is printed in the console.


To see what’s happening in the console put a logger and copy a file in the input folder. Now all the contents of the file is displayed in the console. So try it yourself.


Previous                                                                                                               Next