// write file - overwrite
def filename = "/tmp/text1.txt"
def file = new File(filename)
def w = file.newWriter()

w << "Hello World!"
w.close()

// read file
String r = new File('/tmp/text1.txt').text
println(r)

============= Output =============
Hello World!

dreamtails 發表在 痞客邦 PIXNET 留言(0) 人氣()