zoukankan      html  css  js  c++  java
  • beanshell

    #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();
  • 相关阅读:
    WebApp 里Meta标签大全,webappmeta标签大全
    写给自己的Java程序员学习路线图
    JAVA学习路线图
    JavaScript经典作用域问题(转载)
    js 判断当前操作系统是ios还是android还是电脑端
    css动画,展开折叠图标
    CSU 1335 高桥和低桥
    codevs 1341 与3和5无关的数
    noi 7827 质数的和与积
    51nod 1082 与7无关的数
  • 原文地址:https://www.cnblogs.com/Mezhou/p/13699592.html
Copyright © 2011-2022 走看看