I created a tool to manually upload any
test files into blob column in a table for my development.
The tool is created by Talend open studio.
The file name is put into tFixedFlowInput component.
The file name is put into tFixedFlowInput component.
This is tMap setup.
This is the tDB2Output setup.
From the tMap above, you may see I have a routine, ReadfromFile. (circle in red.)
The code for this routine is as below.
package routines;
public class ReadfromFile {
public static byte[] ByteArrayFromFile(String filepath) {
try{
System.out.println(filepath);
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;
}
}
}
No comments:
Post a Comment