package keTangTest;
import java.io.File;
import java.io.FileFilter;
public class FileDemo7 {
public static void main(String[] args) {
File file = new File("D:/1701/第二周");
File[] files = file.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
if (!pathname.exists()) {
try {
throw new IllegalAccessException(pathname + "文件不存在");
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (!pathname.isDirectory()) {
try {
throw new IllegalAccessException(pathname + "文件夹不存在");
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
File[] files = pathname.listFiles();
for (File file : files) {
if (file.isDirectory()) {
((FileFilter) file).accept(pathname);
}else{
System.out.println(file.getPath());
}
}
}
return false;
}
});
}
}
import java.io.File;
import java.io.FileFilter;
public class FileDemo7 {
public static void main(String[] args) {
File file = new File("D:/1701/第二周");
File[] files = file.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
if (!pathname.exists()) {
try {
throw new IllegalAccessException(pathname + "文件不存在");
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (!pathname.isDirectory()) {
try {
throw new IllegalAccessException(pathname + "文件夹不存在");
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
File[] files = pathname.listFiles();
for (File file : files) {
if (file.isDirectory()) {
((FileFilter) file).accept(pathname);
}else{
System.out.println(file.getPath());
}
}
}
return false;
}
});
}
}