Situatie
To delete a file in Java, use the delete() method:
Solutie
import java.io.File; public class DeleteFile { public static void main(String[] args) { File myObj = new File("test.txt"); if (myObj.delete()) { System.out.println("Deleted the file: " + myObj.getName()); } else { System.out.println("Failed to delete the file."); } } }
Leave A Comment?