EN
Java - file delete
0
points
In this article, we would like to show you how to delete files in Java.
Practical example
import java.io.File;
public class Example {
public static void main(String[] args) {
File file = new File("C:\\path\\to\\file.txt");
if (file.delete()) {
System.out.println("File deleted.");
} else {
System.out.println("Delete failed!");
}
}
}
Result: