Groovy读写文件
/** * @author :ZackZhou * @date :Created in 2020/9/15 2:04 PM * @description : * @modified By: * @version: */ //write file and read content //short file def short_file = new File("./practice_07.groovy") def content = short_file.text println(content) //large file def large_file = new File("./practice_07.groovy") large_file.withReader {reader -> def line while((line = reader.readLine()) != null) println(line) } //another style large_file.eachLine {line -> println(line)} //write content def w_file = new File("./content.txt") w_file.withWriter { writer -> 100.times {writer.append("Hello \n")} }