How to delete a file using SSJS in XPages

It’s easy to do file deletion operation using java.io.File class because the class provides us a delete() method, but unfortunately you can’t use that method inside Domino Designer’s SSJS editor, you will get a syntax error if you try to do so.

So, here’s a workaround (credited to Mark Leusink) I put here for my own reference

var f:java.io.File = new java.io.File( "path" );
var deleteMethod = f.getClass().getDeclaredMethod("delete", null);
deleteMethod.invoke( f , new java.lang.Object[0] );

Leave a Comment

Your email address will not be published. Required fields are marked *