new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
18
Task/Delete-a-file/Java/delete-a-file.java
Normal file
18
Task/Delete-a-file/Java/delete-a-file.java
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import java.util.File;
|
||||
public class FileDeleteTest {
|
||||
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[]) {
|
||||
test("file", "input.txt");
|
||||
test("file", File.seperator + "input.txt");
|
||||
test("directory", "docs");
|
||||
test("directory", File.seperator + "docs" + File.seperator);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue