简单BeanShell例子
1.获取到变量写入文件根据json获取数据,写入文件(1) json获取数据(2) 用beanshell写入文件
1.获取到变量写入文件
根据json获取数据,写入文件
(1) json获取数据
(2) 用beanshell写入文件
public static void writeHeaderFile(){
try {
FileWriter file = new FileWriter("test.txt", true);
int fileLen = Integer.parseInt("${rfxHeaderId_matchNr}");
for(int i=1; i <= fileLen; i++) {
file.write(vars.get("rfxHeaderId_"+i)+"\r\n");
}
file.flush();
file.close();
}catch (IOException e) {
e.printStackTrace();
}
}
writeHeaderFile();
这里要写入的变量是rfxHeaderId_1,rfxHeaderId_2 … rfxHeaderId_10 这里这个变量可以根据函数获取,$(__V(…)) 我们使用的是vars.get(“rfxHeaderId_”+i)+"\r\n" 以上两种方式都可