
Groovy
DaveeChen
呵呵
展开
-
Groovy的list和map
java作为一门强大的系统编程语言,已经在世界各地广泛地应用.groovy是增强java平台的唯一脚本语言,它的语法更加简洁,能快速开发.List:定义list:def list = []list = [1,2,3,4,5]list操作:def list = [1,2,3,4,5]list[1] //Result: 2list[-2] ...2010-03-05 22:49:16 · 346 阅读 · 0 评论 -
Groovy闭包
1.闭包可以是指针,也可以直接调用,还可以将其作为参数传递:def closure = {x-> x*3}closure.call('h') //Result: "hhh"def method(clo) { clo.call('h')}method(closure) //Result: "hhh"method() {x-> x*3} //Result:...2010-03-21 16:42:27 · 107 阅读 · 0 评论 -
排序Map键值对
//将Map键值对按值降序排序,返回指定个键值对static def sortor(map, resultLength) { def resultList = [] if (!map.isEmpty()) { def vals = map.values().toArray() def keys = map.keySet().toArr...原创 2010-01-18 18:45:09 · 141 阅读 · 0 评论 -
dateUtil
/** * 取得上周日 */static def getLastSunday() { def lastSunday def dateFormat = new java.text.SimpleDateFormat('yyyy-MM-dd') dateFormat.format(new Date()) Calendar calendar = dateFormat.getCa...原创 2010-01-25 11:01:14 · 90 阅读 · 0 评论 -
Groovy
//字符串部分值排序def valueList = ['12035-52-16152','11265-84-18452','12005-65-18452']valueList.sort {x, y-> def xlist = [] def yList = [] xlist = x.split('-').toList() - [''] yList = ...原创 2010-01-26 15:36:33 · 107 阅读 · 0 评论 -
Groovy数组取最大值和最小值
//数值def list = [15,13,18,30]println list.min() //Result: 13println list.max() //Result: 30//字符串def strList = ['abc','aab','bac']println strList.min() //Result: aabprintln strList.max() /...原创 2010-01-26 15:38:16 · 1880 阅读 · 0 评论 -
上传图片到服务器
//gsp页面代码原创 2010-02-03 18:30:20 · 131 阅读 · 0 评论 -
Groovy字符串很groovy
字符串定义:1.'' //一般字符串,不解析表达式eg:def mess = 'Hello.''I say ${mess}' //Result: "I say ${mess}"2."" //一般字符串,解析表达式eg:def mess = 'Hello.'"I say ${mess}" //Result: "I say Hello."3.''''...2010-03-02 23:07:07 · 154 阅读 · 0 评论