Opening a File into the GroovyConsole programmatically

Groovy 1.6 (still in beta) has introduced a new handy method into the Groovy Console : loadScriptFile. That allows you to load a script and open it into the Groovy Console. Here are the few lines of code to make it work.

import groovy.ui.Console;

Console console = new Console();
console.run();
console.loadScriptFile("C:/My documents/MyScript.groovy");

That‘s it.

Leave a Reply