new tasks
This commit is contained in:
parent
2a4d27cea0
commit
80737d5a6a
1194 changed files with 15353 additions and 1 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