I have org.apache.commons.vfs.FileObject in my code and after the task is complete I need to delete the file. for which FileObject has delete () method. But it throws FileSystemException.
I did check if there there is file exist, and further delete the file.
FileObject doc2Delete = VFS.getManager().resolveFile("C:\test.pdf");
if (doc2Delete.exists()) {
try {
doc2Delete.delete();
} catch (FileSystemException fse) {
fse.printStackTrace();
}
I expect the file to be deleted but it throws FileSystemException .
On checking file status, it was found not closed. So started working after closing the file