Double-click the cFile component labeled
Sender to open its Basic settings view in the Component tab.
In the Path field, fill in or browse to
the path to the folder that holds the source files.
From the Encoding list, select the
encoding type of your source files. Leave the other parameters as they
are.
Repeat these step to define the output file path and encoding type in the
Basic settings view of the other
cFile component, which is labeled
Receiver.
Double-click the cProcessor component labeled Throw_exception to open its Basic settings view in the Component tab, and customize the code in the Code area to throw an exception and display
relevant information if any file coming via the try connection does not meet the content requirement, as
follows:
String body = exchange.getIn().getBody(String.class);
System.out.println("\nTrying: "+body);
Exception e = new Exception("Only 'Talend Integration Solutions' is acceptable. Please check the file:");
if(!"Talend Integration Solutions".equals(body)){
throw e;
}else{
System.out.println("File is good.");
}
Click the catch connection and then the Component tab to open its Basic settings view, and fill the Expression field with an expression to specify the type of
exception to catch.
In this scenario, fill in Exception.class to catch any exception
thrown.
Double-click cProcessor component labeled Show_exception to open its Basic settings view in the Component tab, and customize the code in the Code area to display the exception information
and the related file name, as follows: