2014-01-17 05:32:22 +00:00
|
|
|
import java.io.File;
|
2020-02-17 23:21:07 -08:00
|
|
|
|
2013-04-10 12:38:42 -07:00
|
|
|
public class FileDeleteTest {
|
2020-02-17 23:21:07 -08:00
|
|
|
public static boolean deleteFile(String filename) {
|
|
|
|
|
boolean exists = new File(filename).delete();
|
|
|
|
|
return exists;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void test(String type, String filename) {
|
|
|
|
|
System.out.println("The following " + type + " called " + filename +
|
|
|
|
|
(deleteFile(filename) ? " was deleted." : " could not be deleted.")
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String args[]) {
|
2013-04-10 12:38:42 -07:00
|
|
|
test("file", "input.txt");
|
|
|
|
|
test("file", File.seperator + "input.txt");
|
|
|
|
|
test("directory", "docs");
|
|
|
|
|
test("directory", File.seperator + "docs" + File.seperator);
|
2020-02-17 23:21:07 -08:00
|
|
|
}
|
2013-04-10 12:38:42 -07:00
|
|
|
}
|