zoukankan      html  css  js  c++  java
  • jmeter:清除本地指定目录下的所有类型文件

    1,创建一个sampler

    2,要在本地有一个目录的文件

    3,直接上代码

           

    String path = "C:\临时文件\test111" ; 
            File file = new File(path);
            if (!file.exists()) {
                System.out.println("目录不存在" + "the dir is not exists !");
                return false;
            }
            String[] content = file.list();//取得当前目录下所有文件和文件夹
            for (String name : content) {
                File temp = new File(path, name);

                if (temp.isDirectory()) {
                    //判断是否是目录  
                    temp.delete();
                    //删除空目录  
                } else {
                    if (!temp.delete()) {
                        //直接删除文件
                        System.err.println("Failed to delete " + name);
                    }

                }
    return true;

    log.info("删除成功 "); 
        }
    ---------------------
    作者:qq_36806145
    来源:CSDN
    原文:https://blog.csdn.net/qq_36806145/article/details/87348559
    版权声明:本文为博主原创文章,转载请附上博文链接!

    jmeter 删除文件:

    String path="${filetoken}";
    File file=new File(path);
    file.delete();

    jmeter 将变量写入到文件:

    filetoken="${filetoken}";
    token=vars.get("token");

    log.info(token);

    f= new FileOutputStream(filetoken,true);


    p= new PrintStream(f);

    this.interpreter.setOut(p);

    print(token);

    f.close();

      

  • 相关阅读:
    感知器算法--python实现
    PHP appserv + ZendStudio12.5.1 + 注册码
    第九周-每周例行报告
    第八周-每周例行报告
    感谢THUNDER
    第七周-每周例行报告
    第六周-每周例行报告
    第五周-每周例行报告
    第四周-四则运算试题生成
    第四周-单元测试
  • 原文地址:https://www.cnblogs.com/python-xiakaibi/p/11294651.html
Copyright © 2011-2022 走看看