通过文件名搜索目录
/** * n o w j a v a . c o m - 时 代 Java 提 供 **/ //package com.nowjava; import java.io.File; public class Main { public static void main(String[] argv) throws Exception { String path = "nowjava.com"; String target = "nowjava.com"; searchDir(path, target); } public static void searchDir(String path, String target) { File f = new File(path); if (path != null) { if (f.isDirectory()) { File[] fileArray = f.listFiles(); if (fileArray != null) { for (File file : fileArray) { searchDir(file.getPath(), target); //????/*时 代 J a v a 公 众 号 提供*/ }