import java.io.*;
public class TestExceptionScan {
public static void main(String[] args) {
readFile("D:\\workspace\\service\\service-uaa\\src\\main\\java","Exception(");
}
public static boolean readFile(String filepath,String scanText){
try {
File file = new File(filepath);
if (!file.isDirectory()) {
readContents(file,scanText);
} else if (file.isDirectory()) {
File[] fileList = file.listFiles();
for (File readFile : fileList) {
if (!readFile.isDirectory()) {
readContents(readFile,scanText);
} else if (readFile.isDirectory()) {
readFile(readFile.getAbsolutePath(),scanText);
}
}
}
} catch (Exception e){
e.printStackTrace();
}
return true;
}
public static void readContents(File file,String scanText){
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(file));
while(br.ready()){
String str = br.readLine();
if (str.indexOf(scanText) > 0) {
System.out.println(str);
}
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}