Here you can find the source of clearFilesOnPath(String path)
public static boolean clearFilesOnPath(String path)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static boolean clearFilesOnPath(String path) { File dir = new File(path); if (!dir.exists()) { System.out.println(path + " does not exists"); return false; }//from ww w .ja v a 2s . c o m if (!dir.isDirectory()) { System.out.println(path + " is not directory"); return false; } File[] files = dir.listFiles(); System.out.println("deleting " + path + " (" + files.length + " files)"); for (int i = 0; i < files.length; i++) { if (files[i].isFile()) { // System.out.println("deleting " + files[i] ); if (!files[i].delete()) { return false; } } } return true; } }