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();

      

  • 相关阅读:
    Confluence 6 尝试从 XML 备份中恢复时解决错误
    Confluence 6 XML 备份恢复失败的问题解决
    Confluence 6 找到在创建 XML 备份的时候出现的错误
    Confluence 6 XML 备份失败的问题解决
    c trans
    How To Use API Online?
    c string
    c function
    c array
    FileCopy
  • 原文地址:https://www.cnblogs.com/python-xiakaibi/p/11294651.html
Copyright © 2011-2022 走看看