首页 软件开发 代码片段 groovy ( Page 3 )

groovy 77

#Groovy
grails 通过applicationContext获取bean

class ShopService{ def grailsApplication def test(){ grailsApplication.mainContext.getBean…

2015-12-14 979

#Groovy
Groovy计算个人所得税。

def salary=7200; def tax=0.00; //只定义到了第5档,这个已经很难达到了 def taxRateMap=[3500:0.03,5000:0.1,800…

2015-12-14 918

#Groovy
groovy 关键字 in 判断集合包含的用法

def list = [1,2,3,4] println (1 in list)// print true

2015-12-14 672

#Groovy
grooy随机生成合法身份证号码的脚本

def rand = new Random() def w = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] def …

2015-12-14 455

#Groovy
Groovy脚本替换多文件中的文本

def currentDir = new File("d:/bakup"); def backupFile; def fileText; //Replace the content…

2015-12-14 210

#Groovy
对db4o的再包装

/** * */ @Typed package org.lucifer.db4o import org.lucifer.util.MyLogger import com.db4o.…

2015-12-14 481

#Groovy
重命名文件

//---------------------------------------------------------------------------------- names…

2015-12-14 350

#Groovy
groovy对双目运算符语法的改进

//一般的双目运算符是这样 String name=""; String txt = (!name.equals("")) ? name : "123" //groovy小改进了一…

2015-12-14 830

#Groovy
Groovy的times循环方法

for (i = 0; i < 5; ++i) { println i }

2015-12-14 503

#Groovy
Groovy菜鸟来解决"易语言难题”

(123..329).each {if(((it+"${it*2}"+it*3).replaceAll('0','').toCharArray() as Set).size()==…

2015-12-14 404

#Groovy
给标准Java库的Math类的方法穿了件外衣

/** * */ @Typed package org.lucifer.util import static java.lang.Math.* /** * @author Luci…

2015-12-14 791

#Groovy
解决grails导出excel的中文件名乱码问题

class XlsController{ /** * 字符串编码 */ final def encode(String value,String charSet='UTF-8'){…

2015-12-14 898