The problem is probably because the file is open. If at some point in your program the file is opened, make sure its closed before deleting it.
eg:
FileInputStream in = new FileInputStream ("c:/a.txt");
make sure you have
in.close();
before using delete.