Here you can find the source of deleteFiles(List
Parameter | Description |
---|---|
files | The files to delete |
public static List<File> deleteFiles(List<File> files)
//package com.java2s; /*/*from w ww . j av a 2 s .c o m*/ * Copyright 1997-2016 Unidata Program Center/University Corporation for Atmospheric Research * Copyright 2010-2015 Jeff McWhirter * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or (at * your option) any later version. * * This library 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 Lesser * General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { /** * This deletes the files in the given list. * It will return a list of those files where file.delete was not successful * * @param files The files to delete * @return List of unsuccessfully deleted files */ public static List<File> deleteFiles(List<File> files) { List<File> notDeleted = new ArrayList<File>(); for (File f : files) { if (!f.delete()) { notDeleted.add(f); } } return notDeleted; } }