Deleting file using Java

Hello All,

I’m new to writing Java agent(s).

Somehow managed to write one that checks for an attachment in the document , extracts it to the local machine and while compisong the mail attaches it to it . Till here everything is working fine . But I want to delete the file from the local PC once it has been attached to the mail .

Can anyone help me for the same. It’ll be greatly appreciated.

Thanks in advance

Tom

Subject: Deleting file using Java

From the Java Almanac (a good source of small code snippets):

boolean success = (new File(“filename”)).delete();

if (!success) {

// Deletion failed

}

http://www.exampledepot.com/egs/java.io/DeleteFile.html

http://www.exampledepot.com

Interacting with the file system will potentially create security issues. Check the security settings of the agent properties if you get a security exception. Worst case you’ll have to deal with the …\lotus\notes\jvm\lib\security\java.policy file…

Good luck.