1、删除某个目录下的所有文件

    /**
     * <p>Removes all files from specified directory.</p>
     *
     * @param path path to directory
     */
    public static void removeFiles(String path) {
        File dir = new File(path);
        if (dir.exists() || dir.isDirectory()) {

 

            for (File file : dir.listFiles()) {
                file.delete();
            }
        }
    }

    一般在tearDown中要删除output中测试产生的文件,调用此方法。

相关文章:

  • 2022-02-26
  • 2021-09-09
  • 2021-12-25
  • 2021-10-18
  • 2021-10-01
  • 2022-02-10
  • 2021-06-27
  • 2022-12-23
猜你喜欢
  • 2021-09-08
  • 2022-01-07
  • 2022-12-23
  • 2021-07-13
  • 2022-02-25
  • 2021-05-27
  • 2022-02-06
相关资源
相似解决方案