将一个字符串转化为java的方法调用主要分为以下几个步骤: 1、定义方法,本文示例定义了一个say的方法,该方法需要两个参数,一个是字符串的数组、一个是写文件的句柄。 public void say(String[] str,PrintWriter pw){ System.out.println("hello "+str[0]+" "+str[3]); pw.println("hello "+str[0]); pw.flush(); pw.close(); } 2、定义转化方法: public void test() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException, IOException{ PrintWriter pw=new PrintWriter(new FileWriter("E://test.txt")); String aa="say"; String ipInfo[]={"1","2","3","4"}; Method sAge = this.getClass().getMethod(aa, new Class[] {String[].class,PrintWriter.class}); //获得参数Object Object[] arguments = new Object[] {ipInfo,pw}; //执行方法 sAge.invoke(this , arguments); }