我有一个名为“silent.txt”的文件。该文件的行如下
bop4InstallDir = myProps.cordys_install_dir + "/" + instanceName
我想将上面的文本替换为
bop4InstallDir = "/abc/xyz/pqr"
使用groovy脚本我该如何完成?
请帮忙。
最佳答案
不是很优雅,但这应该可行。
def file = new File("silent.txt")
file.text = file.text.replace('bop4InstallDir = myProps.cordys_install_dir + "/" + instanceName',
'bop4InstallDir = "/abc/xyz/pqr"')
关于grails - 使用groovy替换文件中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21670269/