add listFiles and isFile methods to java.io.File

This commit is contained in:
Joel Dice
2009-08-04 17:59:07 -06:00
parent 590238bbfc
commit 626c514373
2 changed files with 34 additions and 0 deletions

View File

@ -41,6 +41,12 @@ public class File {
return isDirectory(path);
}
private static native boolean isFile(String path);
public boolean isFile() {
return isFile(path);
}
public String getName() {
int index = path.lastIndexOf(FileSeparator);
if (index >= 0) {
@ -141,6 +147,19 @@ public class File {
return mkdir();
}
public File[] listFiles() {
return listFiles(null);
}
public File[] listFiles(FilenameFilter filter) {
String[] list = list(filter);
File[] result = new File[list.length];
for (int i = 0; i < list.length; ++i) {
result[i] = new File(this, list[i]);
}
return result;
}
public String[] list() {
return list(null);
}