Here you can find the source of deleteAllFilesIn(String dir)
public static void deleteAllFilesIn(String dir)
//package com.java2s; //License from project: Apache License import java.io.File; import java.util.LinkedList; import java.util.List; public class Main { public static void deleteAllFilesIn(String dir) { List<File> files = getAllFilesIn(dir); for (int i = 0; i < files.size(); i++) { files.get(i).delete();/*from ww w. java2 s . c o m*/ } } public static List<File> getAllFilesIn(String dir) { File file = new File(dir); File[] entities = file.listFiles(); List<File> files = new LinkedList<File>(); for (int i = 0; i < entities.length; i++) { File f = entities[i]; if (f.isFile()) { files.add(f); } } return files; } }