Read the text in:
String contents = new File( 'whatever.txt' ).getText( 'UTF-8' )
Replace the text
contents = contents.replaceAll( 'xxx', 'yyy' )
Write the text out again
new File( 'replaced.txt' ).write( contents, 'UTF-8' )
You should be able to wrap them into a task and call the task as normal
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…