I am working on a project which is built on Novell Operations Center which has a scripting engine based on Ecmascript. I am able to address objects in the Java API on which the software is running.
I am trying to remove a file from the file system using the standard Java java.io.File class.
The script is as followed:
var file = new java.io.File('file_path');
file.delete();
This throws an error because “delete” is a reserved word in Ecmascript/Javascript.
Even if I use eval('file.delete()'); I get the same error. Statements like file.exists() or file.canWrite() run as expected.
I am looking for a possible work around to be able to call the delete method on a file object. The deleteOnExit() method won’t work because the server software will not exit on a regular base.
You always can use the bracket notation: