0
grailsでは、印刷メソッドをスクリプトでリダイレクトし、以下に示すようにGroovyShell
を使用して実行することができます。grailsのスクリプトを使用してすべての印刷メソッドの機能を上書きする方法
def scriptText = '''
def s = "Groovy rocks!"
println s
printf 'The answer is %X', 42
'''
def shell = new GroovyShell()
def script = shell.parse(scriptText)
def stringWriter = new StringWriter()
script.out = new PrintWriter(stringWriter)
script.run()
assert stringWriter.toString() == 'Groovy rocks!\nThe answer is 2A'
しかし、私は私を助けてetc.Pleaseファイルに印刷の出力を行うとのprintln、printfのかのprintlnのデフォルトの機能を実行したいです。