Here you can find the source of deleteFiles(File[] files)
Parameter | Description |
---|---|
files | The name of the files to be deleted. |
public static boolean deleteFiles(File[] files)
//package com.java2s; import java.io.File; public class Main { /**/* w w w. ja va 2s .c om*/ * Delete the files and folders passed as parameter. It is recursive, so it deletes the files * included in the subfolders. * * @param files The name of the files to be deleted. * @return <i>True</i> if any file was deleted. <i>False</i> otherwise. */ public static boolean deleteFiles(File[] files) { boolean result = true; for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { result = deleteFiles(files[i].listFiles()) && files[i].delete(); } else { if (files[i].exists()) { result = files[i].delete(); } } } return result; } /** * Delete the files and folders passed as parameter.. * * @param files The name of the files to be deleted. * @return <i>True</i> if any file was deleted. <i>False</i> otherwise. */ public static boolean deleteFiles(String[] files) { boolean result = true; for (int i = 0; i < files.length; i++) { File file = new File(files[i]); if (file.isDirectory()) { result = deleteFiles(file.list()) && file.delete(); } else { if (file.exists() && file.canWrite()) { result = file.delete(); } } file = null; } return result; } }