TDI 6.1.1 – java.io.File delete method

The java.io.File class is a really useful class for those times when you need a little more in terms of file manipulation than the ‘system’ object UserFunctions provide.

However, using this in TDI will throw up a little gotcha that can occur when using the delete method.

For example;

var dirObj = new java.io.File("c:\\temp\\mydir");
dirObj.delete();

Will generate the following error;

com.ibm.jscript.parser.ParseException: Encountered "delete" at line..

The answer is to de-reference the method;

var dirObj = new java.io.File("c:\\temp\\mydir");
dirObj["delete"]();

 

Leave a Reply