查出文件夹中的文件及子文件
package homework;
import java.io.File;
public class Test02 {
public static void main(String[] args) {
File file = new File("d:\\javastest");
System.out.println(file);
//返回String[]
String[] list = file.list();
for(int i=0;i<list.length;i++) {
System.out.println(list[i]);
}
//返回File
File[] fileslist = file.listFiles();
for(int i=0;i<fileslist.length;i++) {
File f = fileslist[i];
if(f.isFile()) {
System.out.println(f.getPath());
}else if(f.isDirectory()) {
if(f.isFile()) {
System.out.println(f.getPath());
}else if(f.isDirectory()){
System.out.println(f.getPath());
}
}
}
}
public static int file(int n) {
return 1;
}
}