Here you can find the source of deleteFile(String strPath, String fileName)
public static final boolean deleteFile(String strPath, String fileName)
//package com.java2s; //License from project: Apache License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static final boolean deleteFile(String strPath, String fileName) { File file = findIt(strPath, fileName); if (file != null) { return file.delete(); }//w w w . java 2 s .co m return false; } public static final File findIt(String strPath, String fileName) { File rootDir = new File(strPath); File[] files = rootDir.listFiles(); List<File> directories = new ArrayList<File>(files.length); for (File file : files) { if (file.getName().equals(fileName)) { return file; } else if (file.isDirectory()) { directories.add(file); } } for (File directory : directories) { File file = findIt(directory.getAbsolutePath(), fileName); if (file != null) { return file; } } return null; } }