import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
//JMeter的内置API:prev.getResponseData()获取请求的响应内容
//byte[] responseData = prev.getResponseData();
// 创建 DateTimeFormatter 对象,指定格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HHmmssSSS");
// 格式化 LocalDateTime 对象
LocalDateTime now = LocalDateTime.now();
String time = "时间:"+formatter.format(now);
//导出的excel存放位置
private String filePath = "E:/fanhcs/返回报文字段.txt";
BufferedOutputStream bos = null;
FileOutputStream fos = null;
File file = null;
String str = vars.get("imageSetId");
try {
File file = new File(filePath);
fos = new FileOutputStream(file,true); //不添加参数true,以非追加的方式添加内容
bos = new BufferedOutputStream(fos);
bos.write((str+time+"\n").getBytes());
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}