I followed the answer to this SO post to write my own script. However, I do not understand how to convert from GStringImpl to String[]. How do I do that?
Thanks
public class TestGroovy {
public static void main(String[] args) {
Binding binding = new Binding();
GroovyShell shell = new GroovyShell(binding);
binding.setVariable("b", "a|b|c");
GStringImpl value = (GStringImpl) shell.evaluate("return \"${b.split('|')}\";");// return "b.split('|')";}
System.out.println(value);
}
}
This prints
[a, |, b, |, c]