Here you can find the source of delete(File f)
public static void delete(File f)
//package com.java2s; /* license-start/*from w ww.j av a 2 s.c o m*/ * * Copyright (C) 2008 - 2013 Crispico Software, <http://www.crispico.com/>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details, at <http://www.gnu.org/licenses/>. * * license-end */ import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class Main { public static void delete(File f) { if (f.isDirectory() && !Files.isSymbolicLink(Paths.get(f.toURI()))) { for (File c : f.listFiles()) { delete(c); } } f.delete(); } }