Jmeter beanshell追加写文件和覆盖写文件方法

上一篇 / 下一篇  2020-02-07 20:48:25 / 个人分类:Jmeter

追加写文件代码:
import org.apache.jmeter.services.FileServer;

// Get the variable(s) from the JMeter script
caseid =vars.get("caseid");


// Open File(s)
f = new FileOutputStream(FileServer.getFileServer().getBaseDir()+"\\output\\output.csv", true); 
p = new PrintStream(f); 

// Write data to file 
p.println(caseid);

// Close File(s)
p.close();
f.close();

覆盖写文件代码:
import org.apache.jmeter.services.FileServer;

// Get the variable(s) from the JMeter script
caseid =vars.get("caseid");


// Open File(s)
f = new FileWriter(FileServer.getFileServer().getBaseDir()+"\\output\\output.csv", true); 

// Write data to file 
f.write(caseid);

// Close File(s)
f.close();


TAG: Jmeter jmeter 写文件

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar