1个回答
展开全部
import java.io.File;
import javax.swing.JOptionPane;
public class T {
public static void main(String[] args) {
String n = JOptionPane.showInputDialog("请输入路径:注意杠\\用/代替");
if (n != null) {
File file = new File(n);
T t = new T();
t.listAllFile(file);
}
}
public void listAllFile(File f) {
if (f.isDirectory()) {
File[] fs = f.listFiles();
for (int i = 0; i < fs.length; i++) {
listAllFile(fs[i]);
}
} else
findDoc(f);
}
public void findDoc(File f) {
String name = f.toString();
if (name.endsWith(".doc")) {
System.out.println(name);
}
}
}
import javax.swing.JOptionPane;
public class T {
public static void main(String[] args) {
String n = JOptionPane.showInputDialog("请输入路径:注意杠\\用/代替");
if (n != null) {
File file = new File(n);
T t = new T();
t.listAllFile(file);
}
}
public void listAllFile(File f) {
if (f.isDirectory()) {
File[] fs = f.listFiles();
for (int i = 0; i < fs.length; i++) {
listAllFile(fs[i]);
}
} else
findDoc(f);
}
public void findDoc(File f) {
String name = f.toString();
if (name.endsWith(".doc")) {
System.out.println(name);
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询