因为没有考虑效率,所以我使用了读取文件然后进行文件内容的处理这种方式进行了代码的编写思路。
读取文件的核心代码
StringBuilder strContent1 = new StringBuilder("");
try {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(f), iCharset));
String iline = null;
while ((iline = br.readLine()) != null) {
strContent1.append(iline.toString());
strContent1.append("\n");
}
br.close();
} catch (IOException e) {
//
}
然后开始进行分析处理
public void parse() {
try {
gydContent.setContent(readFile(this.gytFile));
// 处理include标签
RepInclude();
// 处理判断
RepIf();
// 处理循环
RepFor();
// 处理替换的标签
RepString();
} catch (IOException e) {
e.printStackTrace();
}
}
写这个地方的时候一直比较纠结就是处理的顺序,最后定成这个顺序了。
今天先写到这,以后继续