-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSomeMethods.java
More file actions
31 lines (25 loc) · 905 Bytes
/
Copy pathSomeMethods.java
File metadata and controls
31 lines (25 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package ReflectClass;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.regex.Pattern;
public class SomeMethods {
private static Pattern p=Pattern.compile("\\w+\\.");
public static void getMethod(String clazzName) {
try {
Class<?> c = Class.forName(clazzName);
Method[] methods = c.getMethods();
Constructor[] ctors = c.getConstructors();
for (Method method : methods) {
System.out.println(p.matcher(method.toString()).replaceAll(""));
}
for (Constructor ctor : ctors) {
System.out.println(p.matcher(ctor.toString()).replaceAll(""));
}
}catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
getMethod("ReflectClass.SomeMethods");
}
}