การสร้าง file
def outFile = new File('out.txt')
outFile.delete() // if file exist, delete it
def i = 1
4.times{ // 4 time loop
outFile.append i++ + '\n'
}
การอ่าน file
datafile = new File('out.txt')
datafile.eachLine{ line -> print line + '\n' } // closure
No comments:
Post a Comment