java

/**
 * 递归删除 文件/文件夹
 * @param file
 */
public void deleteFile(File file) {

    Log.i("======", "delete file path=" + file.getAbsolutePath());

    if (file.exists()) {
        if (file.isFile()) {
            file.delete();
        } else if (file.isDirectory()) {
            File files[] = file.listFiles();
            for (int i = 0; i < files.length; i++) {
                deleteFile(files[i]);
            }
        }
        file.delete();
    } else {
        Log.e("======", "delete file no exists " + file.getAbsolutePath());
    }
}

你可能感兴趣的:(java)