Here you can find the source of deleteFileWithSuffix(String path, String suffix)
Parameter | Description |
---|---|
path | the file to be deleted |
suffix | the suffix |
public static boolean deleteFileWithSuffix(String path, String suffix)
//package com.java2s; /*/* w w w . ja v a 2s.c o m*/ * RED: RNA Editing Detector Copyright (C) <2014> <Xing Li> * * RED 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, either version 3 of the License, or (at your option) any later version. * * RED 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. * * You should have received a copy of the GNU General Public License along with this program. If not, see * <http://www.gnu.org/licenses/>. */ import java.io.File; public class Main { /** * Delete the file by a given file path with specific suffix. * * @param path the file to be deleted * @param suffix the suffix * @return true if delete successfully. */ public static boolean deleteFileWithSuffix(String path, String suffix) { boolean flag = false; File file = new File(path); if (file.isFile() && file.exists() && file.getName().endsWith(suffix)) { if (file.delete()) { flag = true; } } return flag; } }