Here you can find the source of deleteFile(String folderName, String fileName)
public static boolean deleteFile(String folderName, String fileName) throws IOException
//package com.java2s; /**//from w w w .jav a 2s. com * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static boolean deleteFile(String folderName, String fileName) throws IOException { Path filePath = Paths.get(folderName, fileName); boolean deleted = Files.deleteIfExists(filePath); return deleted; } public static boolean deleteFile(String fileName) throws IOException { Path filePath = Paths.get(fileName); boolean deleted = Files.deleteIfExists(filePath); return deleted; } }