[Training Video - 4] [Groovy] String Functions
def x="I like to read books before bed"
def temp = x.split(" ")
log.info "Size of array is : "+temp.length
log.info temp[0]
log.info temp[1]
log.info x.substring(2,8)
log.info x.indexOf("t")
log.info x.indexOf("book")
log.info x.indexOf("e",6)
log.info x.charAt(5)
Result:
Tue Jun 16 14:40:49 CST 2015:INFO:Size of array is : 7
Tue Jun 16 14:40:49 CST 2015:INFO:I
Tue Jun 16 14:40:49 CST 2015:INFO:like
Tue Jun 16 14:40:49 CST 2015:INFO:like t
Tue Jun 16 14:40:49 CST 2015:INFO:7
Tue Jun 16 14:40:49 CST 2015:INFO:15
Tue Jun 16 14:40:49 CST 2015:INFO:11
Tue Jun 16 14:40:49 CST 2015:INFO:e
def a = "100"
def b = "200" def c = Integer.parseInt(a) + Integer.parseInt(b)
log.info "sum = " + c def d = 100
def n = String.valueOf(d)
log.info "d = " + d
Result:
Tue Jun 16 14:45:55 CST 2015:INFO:sum = 300
Tue Jun 16 14:45:55 CST 2015:INFO:d = 100
[Training Video - 4] [Groovy] String Functions的更多相关文章
- [Training Video - 3] [Groovy in Detail] Non-static and Static functions, initializing log inside class
log.info "starting" // we use class to create objects of a class Planet p1 = new Planet() ...
- [Training Video - 2] [Groovy Introduction]
Building test suites, Test cases and Test steps in SOAP UI Levels : test step level test case level ...
- [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Exception Handling in groovy
def x = new String[3] x[0] = "A" x[1] = "B" x[2] = "C" log.info"X ...
- [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Array and ArrayList
Array: def x = new String[5] x[0] = "India" x[1] = "USA" x[2] = "Korea" ...
- [Training Video - 4] [Groovy] Optional parameter in groovy
Employee.log=log Employee e1 = new Employee() log.info e1.add(1,2,3,4) // optional parameters in gro ...
- [Training Video - 3] [Groovy in Detail] Non-static and Static variables, objects and object referances
log.info "starting" // we use class to create objects of a class Planet p1 = new Planet() ...
- [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] HashSet and Hashtable
Hashset: HashSet set = new HashSet() set.add("India") set.add("USA") set.add(&qu ...
- [Training Video - 4] [Groovy] Object equality and variable equality check
def x=2 def y=3 if(x == y){ log.info "equal" }else{ log.info "not equal" // prin ...
- [Training Video - 4] [Groovy] Initializing log inside class with constructor
TestService s = new TestService(log,context,testRunner) s.xyz() class TestService{ def log def conte ...
随机推荐
- 《DSP using MATLAB》Problem 2.14
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- POJ2374 Fence Obstacle Course
题意 Language:Default Fence Obstacle Course Time Limit: 3000MS Memory Limit: 65536K Total Submissions: ...
- Linux下用文件IO的方式操作GPIO(/sys/class/gpio)(转)
通过sysfs方式控制GPIO,先访问/sys/class/gpio目录,向export文件写入GPIO编号,使得该GPIO的操作接口从内核空间暴露到用户空间,GPIO的操作接口包括direction ...
- POJ1236学校网络——tarjan
题目:http://poj.org/problem?id=1236 Tarjan+缩点.温习一下Tarjan的写法. 1.在缩点后的TAG中,有几个联通块等价于有几个入度为0的点! 2.把它们都联通相 ...
- IE8 focus 失效解决方案
这几天遇到两个在IE8下focus失效的非常奇怪的问题,当然这个是指JS函数: document.getElementById("id").focus(); 或者 $(" ...
- 锐捷 rg-S2026f 学习笔记
1.通过串口连接交换机: http://support.ruijie.com.cn/forum.php?mod=viewthread&tid=32250&extra=page%3D1& ...
- PLSQL在64位 win7/WIN8上运行(绿色版plsql、无需安装oracle客户端)
一.准备需要的文件: 1.plsql文件绿色压缩包 2.oracle客户端文件绿色压缩包 二.设置PLSQL 运行plsql,不登陆进入plsql点“工具”-“首选项” 按照如图设置“ oracle主 ...
- Java 判断是否包含指定的子串 contains()
Java 手册 contains public boolean contains(CharSequence s) 当且仅当此字符串包含指定的 char 值序列时,返回 true. 参数: s - 要搜 ...
- 1711 Number Sequence(kmp)
Number Sequence Time Limit : 10000/5000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) To ...
- 需登录账号与密码的网页爬取demo
public static String connect(String dataUrl){ String result = null; try { HttpClient httpclient = ne ...