new tasks

This commit is contained in:
Ingy döt Net 2013-04-09 00:46:50 -07:00
parent 2a4d27cea0
commit 80737d5a6a
1194 changed files with 15353 additions and 1 deletions

View file

@ -0,0 +1,20 @@
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
public class FileExistsTest{
private static FileSystem defaultFS = FileSystems.getDefault();
public static boolean isFileExists(String filename){
return Files.exists(defaultFS.getPath(filename));
}
public static void test(String type, String filename){
System.out.println("The following " + type + " called " + filename +
(isFileExists(filename) ? " exists." : " not exists.")
);
}
public static void main(String args[]){
test("file", "input.txt");
test("file", defaultFS.getSeparator() + "input.txt");
test("directory", "docs");
test("directory", defaultFS.getSeparator() + "docs" + defaultFS.getSeparator());
}
}

View file

@ -0,0 +1,18 @@
import java.io.File;
public class FileExistsTest {
public static boolean isFileExists(String filename) {
boolean exists = new File(filename).exists();
return exists;
}
public static void test(String type, String filename) {
System.out.println("The following " + type + " called " + filename +
(isFileExists(filename) ? " exists." : " not exists.")
);
}
public static void main(String args[]) {
test("file", "input.txt");
test("file", File.separator + "input.txt");
test("directory", "docs");
test("directory", File.separator + "docs" + File.separator);
}
}