groovyshell
groovyshell的使用
shell在java中直接new出来即可
GroovyShell shell=new GroovyShell();
List<String> list= new ArrayList<String>();
try {
shell.run(new File("checkAllFileDemo1.groovy"), list);
} catch (CompilationFailedException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
在有些地方,shell.run()中,可以只写file,
shell中,run()和parse()方法很像,但是确实是不同的,
在parse()中,执行的结果不会返回,在run()中,会显示出来,
或者直接使用
GroovyShell shell=new GroovyShell();
try {
shell.evaluate(str)
} catch (CompilationFailedException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}