Here you can find the source of deleteFile(String fileName)
Parameter | Description |
---|---|
fileName | The path for the file |
public static boolean deleteFile(String fileName)
//package com.java2s; //License from project: LGPL import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { /**//www . j ava 2 s .c o m * Deletes the given file * * @param fileName * The path for the file * @return True: If the file was successfully deleted */ public static boolean deleteFile(String fileName) { Path p = Paths.get(fileName); try { return Files.deleteIfExists(p); } catch (IOException e) { e.printStackTrace(); } return false; } }