java根据smil文件路径,获得src在smil文件中出现的次数

/**
* 根据smil文件路径,获得src在smil文件中出现的次数<br>
* >>>>>已通过测试<br>
*
* @param file
* @return
* @throws IOException
*/
public int getSrcCount(String smilFilePath) {
int count = 0;
String find = "src=";
String str;

try {
Reader in = new FileReader(smilFilePath);
BufferedReader bf = new BufferedReader(in);
while ((str = bf.readLine()) != null) {
int len = str.length();
str = str.replaceAll(find, "");

//System.out.println("###str:"+str);
len -= str.length();
count += len / find.length();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("###count:" + count);
return count;

}

你可能感兴趣的:(java)