Saturday, September 12, 2009

การ encode ข้อมูล ด้วย groovy

ตัวอย่าง การ encode ข้อมูล

def outFile = new File('out2.txt')
outFile.delete()
datafile = new File('out.txt')
datafile.eachLine{ line ->
for (c in line) {
outFile.append( (char) ((int)c+1) )
}
outFile.append ('\n')
}
input (out.txt)
--------
This is a boy.
This is a girl.

output (out2.txt)
---------
Uijt!jt!b!cpz/
Uijt!jt!b!hjsm/

การ decode ข้อมูล ก็สามารถทำได้ไม่ยาก เหมือนกันลองไปทำดูครับ

No comments:

Post a Comment