Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
DrGenious
Creator
Creator

Exception rutine

Hi,

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. 

 

Thanks in advance.

 

Labels (2)
0 Replies