提取C++库函数的代码,没有仔细测试。大家可以测试一下,修改一下。
package edu.kevin.regular; import java.io.*; import java.util.*; import java.util.regex.*; public class SrcAnalyze ...{ private String srcDir; private HashSet allAPI; private HashSet inAPI; private Pattern pt; public SrcAnalyze(String dir) ...{ srcDir = dir; allAPI = new HashSet(1000); inAPI = new HashSet(1000); //抽取C++的库函数调用 pt = Pattern.compile(\"(\\b+)(\\w+)\\([^\\)]*\\)(\\s*(\\{)|[^\\{])\"); } public void extract() ...{ Date start = new Date(); long startTime = start.getTime(); extDir(srcDir); for (Object hs : inAPI) ...{ if (allAPI.contains(hs)) ...{ allAPI.remove(hs); } } Date end = new Date(); long endTime = end.getTime(); //计算程序运行时间 System.out.println(\"Time: \" + (endTime - startTime) + \"ms\"); } |