This Code can be used to delete a list of files and in turn the reponse will be a String containg Success or error for every single file.
import java.io.File; import org.apache.log4j.Logger; public class Testing { private static final Logger logger = Logger.getLogger(Testing.class); //This function will delete the file and will return the status. private static boolean deletefile(String file) { File f1 = new File(file); boolean success = f1.delete(); if (!success) { logger.debug("Deletion failed."); System.exit(0); } else { logger.debug("File deleted."); } return success; } public static void main(String[] args) { boolean resultVal; StringBuffer result = new StringBuffer(); if (args[0].length() < 0) { logger.debug("File has not been mentioned."); } else { String[] results = args[0].split(","); for (int i = 0; i < results.length; i++) { logger.debug(results[i]); //call the delete function resultVal = deletefile(results[i]); if (resultVal == true) { result.append("Sucess,"); } else { result.append("Error,"); } } //Delete the last comma appended to the string result.deleteCharAt(result.length() - 1); logger.debug(result); } } }