It has a ByteArrayFromFile function, that requires a
file path as input parameter and is used to read a file and convert it to a
byte array.
package routines;public class MyRoutineDemo {
public static byte[] ByteArrayFromFile(String filepath) {
try{
java.io.File file=new java.io.File(filepath);
java.io.FileInputStream fis = new java.io.FileInputStream(file);
int fileLength = (int) file.length();
byte[] incoming_file_data = new byte[fileLength]; // allocate byte array of right size
fis.read(incoming_file_data, 0, fileLength ); // read into byte array
fis.close();
return incoming_file_data;
}catch(Exception err){
err.printStackTrace();return null;
}
}
}
For more information on how to create user routines, see
the Talend User Guide on Talend Help Center.
For more information on how to create user routines,
see the Talend User Guide on Talend Help Center (https://help.talend.com).