there is a text file, some code is stored there, how can I to group for example the whole for loops, or if, while, and then write them to the collection
For example there is a file that I read and wrote into an array:
0)Class A{
1)if(a>0){
2)a=a+1:
3)System.out.print(a);
4)}
5)if(a<0){
6)for(i=0; i<s.length; i++){
7)words.add(s[i]);
8)}
9)for(i=0; i<s.length; i++){
10)words.add(s[i]);
11)}
12)}
13)for(j=0; j<sap.length; j++){
14)Rep.add(s[i]);
15)System.out.println(s[i]);
16)}
17)for(j=0; j<sap.length; j++){
18)Rep.add(s[i]);
19)System.out.println(s[i]);
20)}
21)}
After regrouping, he should become this:
0)Class A{
1)if(a>0){
a=a+1:
System.out.print(a);
}
2)if(a<0){
3)for(i=0; i<s.length; i++){
words.add(s[i]);
}
4)for(i=0; i<s.length; i++){
words.add(s[i]);
}
}
5)for(j=0; j<sap.length; j++){
Rep.add(s[i]);
System.out.println(s[i]);
}
6)for(j=0; j<sap.length; j++){
Rep.add(s[i]);
System.out.println(s[i]);
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…