- public static void main(String[] args) {
- try {
- BufferedReader br = new BufferedReader(new FileReader("D://1.txt"));
- String temp = null;
- int i=0,j=0,k=0;
- while ((temp = br.readLine()) != null) {
- if (temp.indexOf(("Hibernate:")) != -1) {
- k++;
- int indexFrom = temp.indexOf("from");
- String beforeFROM = temp.substring(0, indexFrom);
- String pro = "";
- while (beforeFROM.indexOf(" as ") != -1) {
- String value = beforeFROM.substring(beforeFROM.indexOf(".")+1,
- beforeFROM.indexOf(" as "));
- pro += value + ",";
- beforeFROM = beforeFROM.substring(beforeFROM.indexOf(" as ")+5,
- beforeFROM.length());
- }
- System.out.println("select "+pro+temp.substring(indexFrom,temp.length()));
- }
- if(temp.indexOf("left outer join")!=-1)
- j++;
- }
- System.out.println("总共有 "+k+" 条SQL语句;其中outer join的有 "+j+" 条");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }