jodd.io.FileUtil.deleteDir()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(312)

本文整理了Java中jodd.io.FileUtil.deleteDir()方法的一些代码示例,展示了FileUtil.deleteDir()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.deleteDir()方法的具体详情如下:
包路径:jodd.io.FileUtil
类名称:FileUtil
方法名:deleteDir

FileUtil.deleteDir介绍

[英]Deletes a directory.
[中]删除一个目录。

代码示例

代码示例来源:origin: redisson/redisson

public static void deleteDir(File dest) throws IOException {
  deleteDir(dest, fileUtilParams);
}
/**

代码示例来源:origin: redisson/redisson

/**
 * Smart delete of destination file or directory.
 */
public static void delete(File dest, FileUtilParams params) throws IOException {
  if (dest.isDirectory()) {
    deleteDir(dest, params);
    return;
  }
  deleteFile(dest);
}

代码示例来源:origin: redisson/redisson

public static void deleteDir(String dest) throws IOException {
  deleteDir(file(dest), fileUtilParams);
}
public static void deleteDir(String dest, FileUtilParams params) throws IOException {

代码示例来源:origin: redisson/redisson

public static void deleteDir(String dest, FileUtilParams params) throws IOException {
  deleteDir(file(dest), params);
}
public static void deleteDir(File dest) throws IOException {

代码示例来源:origin: oblac/jodd

/**
 * @see #deleteDir(File)
 */
public static void deleteDir(final String destDir) throws IOException {
  deleteDir(file(destDir));
}

代码示例来源:origin: oblac/jodd

/**
 * Smart delete of destination file or directory.
 *
 * @throws IOException if there is an issue deleting the file/directory.
 * @see #deleteFile(File)
 * @see #deleteDir(File)
 */
public static void delete(final File dest) throws IOException {
  if (dest.isDirectory()) {
    deleteDir(dest);
    return;
  }
  deleteFile(dest);
}

代码示例来源:origin: redisson/redisson

private static void doMoveDirectory(File src, File dest) throws IOException {
  if (dest.exists()) {
    if (!dest.isDirectory()) {
      throw new IOException(MSG_NOT_A_DIRECTORY + dest);
    }
    dest = file(dest, dest.getName());
    dest.mkdir();
  }
  final boolean rename = src.renameTo(dest);
  if (!rename) {
    doCopyDirectory(src, dest, params());
    deleteDir(src);
  }
}

代码示例来源:origin: redisson/redisson

if (file.isDirectory()) {
  if (params.recursive) {
    deleteDir(file, params);

代码示例来源:origin: oblac/jodd

/**
 * Moves a directory.
 *
 * @param srcDest Source directory
 * @param destDir Destination directory.
 * @throws IOException if there is an error during move.
 */
private static void _moveDirectory(final File srcDest, File destDir) throws IOException {
  if (destDir.exists()) {
    checkIsDirectory(destDir);
    destDir = file(destDir, destDir.getName());
    destDir.mkdir();
  }
  final boolean rename = srcDest.renameTo(destDir);
  if (!rename) {
    _copyDirectory(srcDest, destDir);
    deleteDir(srcDest);
  }
}

代码示例来源:origin: oblac/jodd

/**
 * Cleans a directory without deleting it.
 *
 * @param destDir destination to clean.
 * @throws IOException if something went wrong.
 */
public static void cleanDir(final File destDir) throws IOException {
  checkExists(destDir);
  checkIsDirectory(destDir);
  File[] files = destDir.listFiles();
  if (files == null) {
    throw new IOException("Failed to list contents of: " + destDir);
  }
  IOException exception = null;
  for (File file : files) {
    try {
      if (file.isDirectory()) {
        deleteDir(file);
      } else {
        file.delete();
      }
    } catch (IOException ioex) {
      exception = ioex;
      continue;
    }
  }
  if (exception != null) {
    throw exception;
  }
}

代码示例来源:origin: oblac/jodd

@Test
void testZipBuilderFile() throws IOException {
  File zipFile = new File(dataRoot, "test.zip");
  ZipBuilder.createZipFile(zipFile)
    .add(new File(dataRoot, "sb.data"))
      .path("sbdata").comment("This is sb data file").save()
    .add(new File(dataRoot, "file"))
      .path("folder").comment("This is a folder and all its files").save()
    .toZipFile();
  assertTrue(zipFile.exists());
  ZipUtil.unzip(zipFile, new File(dataRoot), "sbda*");
  assertTrue(new File(dataRoot, "sbdata").exists());
  assertFalse(new File(dataRoot, "folder").exists());
  ZipUtil.unzip(zipFile, new File(dataRoot));
  assertTrue(new File(dataRoot, "sbdata").exists());
  assertTrue(new File(dataRoot, "folder").exists());
  assertTrue(new File(new File(dataRoot, "folder"), "a.png").exists());
  // cleanup
  FileUtil.delete(new File(dataRoot, "sbdata"));
  FileUtil.deleteDir(new File(dataRoot, "folder"));
  FileUtil.delete(zipFile);
}

代码示例来源:origin: oblac/jodd

FileUtil.deleteDir(new File(dataRoot, "folder"));
FileUtil.deleteDir(new File(dataRoot, "folder2"));
FileUtil.delete(zipFile);

代码示例来源:origin: oblac/jodd

FileUtil.deleteDir(tmp2);
  FileUtil.deleteDir(tmp3);
} catch (IOException ioex) {
  fail(ioex.toString());

代码示例来源:origin: oblac/jodd

assertNull(res);
FileUtil.deleteDir(tempRoot);

代码示例来源:origin: oblac/jodd

FileUtil.deleteDir(attFolder);

代码示例来源:origin: org.jodd/jodd-core

/**
 * @see #deleteDir(File)
 */
public static void deleteDir(final String destDir) throws IOException {
  deleteDir(file(destDir));
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Smart delete of destination file or directory.
 *
 * @throws IOException if there is an issue deleting the file/directory.
 * @see #deleteFile(File)
 * @see #deleteDir(File)
 */
public static void delete(final File dest) throws IOException {
  if (dest.isDirectory()) {
    deleteDir(dest);
    return;
  }
  deleteFile(dest);
}

代码示例来源:origin: yandex-qatools/embedded-services

@Override
  public void stop() {
    if (!stopped) {
      logger.info("Shutting down the embedded service...");
      started = false;
      try {
        doStop();
        stopped = true;
        if (removeDataDir) {
          try {
            deleteDir(new File(dataDirectory));
          } catch (Exception e) {
            logger.error("Failed to remove data dir", e);
          }
        }
      } catch (Exception e) {
        logger.error("Failed to stop service", e);
      }
    }

  }
}

代码示例来源:origin: ru.yandex.qatools.embed/embedded-services

@Override
  public void stop() {
    if (!stopped) {
      logger.info("Shutting down the embedded service...");
      started = false;
      try {
        doStop();
        stopped = true;
        if (removeDataDir) {
          try {
            deleteDir(new File(dataDirectory));
          } catch (Exception e) {
            logger.error("Failed to remove data dir", e);
          }
        }
      } catch (Exception e) {
        logger.error("Failed to stop service", e);
      }
    }

  }
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Moves a directory.
 *
 * @param srcDest Source directory
 * @param destDir Destination directory.
 * @throws IOException if there is an error during move.
 */
private static void _moveDirectory(final File srcDest, File destDir) throws IOException {
  if (destDir.exists()) {
    checkIsDirectory(destDir);
    destDir = file(destDir, destDir.getName());
    destDir.mkdir();
  }
  final boolean rename = srcDest.renameTo(destDir);
  if (!rename) {
    _copyDirectory(srcDest, destDir);
    deleteDir(srcDest);
  }
}

相关文章