This means the String path which is passed on constructor will be for String variable x. And after creating object of Xls_reader class we will use methods from Xls_Reader.Java to read all keywords?
I tried the following code to read Xlsx using Reflections and then call the corresponding methods :
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Practice {
public static void main(String[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Xls_Reader dbt=new Xls_Reader("D:\\testing\\Data.xlsx");
for(int i=2;i<=dbt.getRowCount("Record");i++){
for(int j=0;j<dbt.getColumnCount("Record");j++){
String a=dbt.getCellData("Record", j,i);
Method method = Practice.class.getMethod(a);
method.invoke(method);
}
}
}
public static void Sankalp(){
System.out.println("hello");
}
public static void Mumbai(){
System.out.println("hi");
}
}
Although it is calling the 2 functions defined, I am getting the following Exception :
hello
hi
Exception in thread "main" java.lang.NoSuchMethodException: Practice.()
at java.lang.Class.getMethod(Unknown Source)
at Practice.main(Practice.java:15)
Please help