groovy

替换:
    def replace = { file, s1, s2 ->
        def text = file.text.replaceAll(s1, s2)
        file.withPrintWriter{ printWriter ->
            printWriter.println(text)
        }
    }
    def dir = new File("groovyTest/1/AndroidManifest.xml")
    replace(dir, 'versionCode=\"[0-9]*\"', 'versionCode=\"11211\"')


运行终端命令:
    def proc = "sh sh_test.sh".execute()
    println proc.text

在指定目录下执行命令
def f = new File("1")
def command = "groovy groovyTest.groovy"
def proc = command.execute(null, f)
proc.waitFor()
print proc.text

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 官方文档 The Apache Groovy programming language Groovy Langua...
    LeonXtp阅读 539评论 0 0
  • groovy是什么 Groovy 是下一代的Java语言,跟java一样,它也运行在 JVM 中。 作为跑在JVM...
    ronaldo18阅读 711评论 0 4
  • 什么是 Groovy? 简言之,Groovy是一种基于JVM(Java虚拟机)的敏捷动态开发语言。它是一种成熟的面...
    北纬26阅读 4,162评论 0 14
  • 摘要: 从头开始手把手教你新建一个SoapUI Project. 重点看是如何操作Excel中的Propertie...
    Vicky_习惯做唯一阅读 3,479评论 0 9
  • 人生在世多样化 不知道哪天你就是一个变数 那么不要多虑多想 努力做好自己 首先要学会涵养礼貌 其次要始终记得告诉自...
    泠念蝶阅读 245评论 3 3