需要反射来执行一个带有Main方法的类,而这个Main方法还有需要对控制台的输入进行处理 要怎么弄啊?
例如
测试类:
public class Test{    public static void main(String[] args) throws Exception{
        // TODO Auto-generated method stub
        Method me = Class.forName("Main").getMethod("main",String [].class);
        me.invoke(null, (Object) new String[]{"123,12"});
    }}
需要调用的类:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;public class Main {    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = null;
        while ((str = br.readLine()) != null) {
            Scanner sc = new Scanner(str);
            System.out.println(sc.nextInt() + sc.nextInt());
        }
    }}