Here you can find the source of deleteFile(String fileName)
Parameter | Description |
---|---|
fileName | the file to delete (full path) |
public static boolean deleteFile(String fileName)
//package com.java2s; import java.io.File; public class Main { /**//w w w . j a v a 2s .c om * delete a file from the system, if exists * * @param fileName * the file to delete (full path) * @return false if file doesn't exist or is a directory */ public static boolean deleteFile(String fileName) { File file = new File(fileName); if (!file.exists() || file.isDirectory()) { return false; } file.delete(); return true; } public static boolean exists(String fileName) { File file = new File(fileName); return file.exists(); } }