#uuid获取,变字符串,变大写,去除特殊符号-
import java.util.UUID; UUID uuid1 = UUID.randomUUID(); vars.put("str",(uuid1.toString()).toUpperCase().replaceAll("-","")); log.info("---------------------------------------"+vars.get("str")); //vars.put("str",Thread.currentThread().getName()+""); //log.info("---------------------------------------"+vars.get("str"));
#纳米时间戳
long timeStamp = System.nanoTime(); vars.put("timeStamp",timeStamp+""); log.info("---------------------------------------"+vars.get("timeStamp"));
导出excel,写excel
//获取导出请求的响应内容 byte[] responseData = prev.getResponseData(); //响应头中的文件名称拼接保存路径 private String filePath = "D:/zjr/excel/${exportFile}"; //将导出结果保存至指定路径对应的文件中 BufferedOutputStream bos = null; FileOutputStream fos = null; File file = null; try { File file = new File(filePath); fos = new FileOutputStream(file); bos = new BufferedOutputStream(fos); bos.write(responseData); } catch (Exception e) { e.printStackTrace(); } finally { if (bos != null) { try { bos.close(); } catch (IOException e) { e.printStackTrace(); } } if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } }
保存接口返回的pdf并落地到指定位置:
long timeStamp = System.nanoTime(); vars.put("timeStamp",timeStamp+""); log.info("---------------------------------------"+vars.get("timeStamp")); import java.io.*; byte[] result = prev.getResponseData(); String file_name = "C:/Users/Administrator/Desktop/cqs/result/test_"+timeStamp+".pdf"; File file = new File(file_name); FileOutputStream out = new FileOutputStream(file); out.write(result); out.close();