我已阅读源代码并将其内容存储在String中,如下所示: -
String s="the code of the source file i am reading";
我已经尝试了几次
String s="source code";
String[] lines=s.split("\n");//split my source code into lines
之后我不知道如何逐行找到标识符
答案 0 :(得分:1)
您需要Java Reflection来阅读更多here,
public class ReflectFoo2Class {
public ReflectFoo2Class(){
Foo2 f = new Foo2();
Field[] field;
try {
field = f.getClass().getFields();
for(Field fa: field){
System.out.println(fa.getName());
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[]args){
new ReflectFoo2Class();
}
}
class Foo2 {
public String v = "";
public String v1 = "";
public String v2 = "";
public void print() {
System.out.println("abc");
}
}