Deleting a File
Deleting a File
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.IOException;
public class DeleteFileExample {
public static void main(String[] args) {
String filePath = "output.txt";
Path path = Paths.get(filePath);
try {
Files.delete(path);
System.out.println("File deleted successfully");
} catch (IOException e) {
e.printStackTrace();
}
}
}
Semantic portal