how to replace a string/word in a text file in groovy

前端 未结 6 2238
难免孤独
难免孤独 2020-12-05 22:57

Hello I am using groovy 2.1.5 and I have to write a code which show the contens/files of a directory with a given path then it makes a backup of the file and replace a word/

6条回答
  •  情书的邮戳
    2020-12-05 23:47

    As with nearly everything Groovy, AntBuilder is the easiest route:

    ant.replace(file: "myFile", token: "NEEDLE", value: "replacement")
    

提交回复
热议问题