In tjava I have this code for checking the values :
File directory = new File(context.main_path+"/Logs/test/");
if (! directory.exists()){
directory.mkdirs();
}
PrintWriter pw = null;
try {
//path of the target file
File file = new File(context.main_path+"/Logs/test/test.csv");
//enable appending in the file if it exists
//if it doesn't exist it will be created
FileWriter fw = new FileWriter(file, true);
pw = new PrintWriter(fw);
//print in file the timestamp, when the error occured + generic problem
pw.println(TalendDate.formatDate("yyyy-MM-dd HH:mm:ss", TalendDate.getCurrentDate()) + " , " + "Error in reading file: " + ((String)globalMap.get("tWaitForFile_1_FILENAME")) + " , " + "Error: " + input_row.errorMessage);
//print in file the specific errorMessage
//pw.println(input_row.errorMessage);
}
catch (IOException e) {
e.printStackTrace();
}
finally {
if (pw != null) {
pw.close();
}
}
I want to ask if there is any way in order to make this code as a routine and just call it in my component instead of write every time this code.