/** * 递归查找文件 * @param basePath * @param methodName * @return */ private String Recurisive(String basePath, String methodName) { // TODO Auto-generated method stub File file = new File(basePath); File[] files = file.listFiles(); if(files==null) { return result; } String fileName = null; for (int i = 0; i < files.length; i++) { fileName = files[i].getName(); if(files[i].isDirectory()==true) { Recurisive(basePath+fileName+"/",methodName); }else{ result = searchMethod(basePath,methodName,fileName); if(!result.equals(UN_USER)) { /*当搜索到关键字,则通过异常一次性跳出递归*/ throw new StopRecException(); } } } return result; } static class StopRecException extends RuntimeException { /** * */ private static final long serialVersionUID = 1L; }