I need some help with deleting the file in Mule application. Here is my use case:
I get a file using File Inbound Endpoint, get the data and upload the data to the database after doing some validations on the data.
I would like to delete the file after uploading to database is successful. I tried using java.io.File.delete(as suggested in the this stackoverflow post) but it's not working.
Mule - Delete files with Files Connector
I am using Mule 3.3.2 and running the server on my local machine. (I am able to delete the file when I delete using a simple Java program.)
Could you please help?
----UPDATE---- This is what I have in my OnCall() method of the Java component I am using to delete the file. isDeleted returns false.
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
String fileName = (String) eventContext.getMessage().getProperty(
"originalFilename");
filePath = "C:\\REP-UNZIP\\";
File file = new File(filePath + fileName);
boolean isDeleted = false;
isDeleted = java.nio.file.Files.deleteIfExists(file.toPath());
if (file.isFile()) {
isDeleted = file.delete();
}
// isDeleted = FileUtils.deleteQuietly(file); LOG.info("isDeleted = " + isDeleted);
return Boolean.valueOf(isDeleted);
}