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

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

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

FileUtil.checkIsDirectory介绍

[英]Checks if File is a directory. Throws IOException if not.
[中]检查文件是否为目录。如果不是,则抛出IOException。

代码示例

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

/**
 * Checks if directory exists. Throws IOException if it does not.
 *
 * @param dir Directory
 * @throws IOException if directory does not exist.
 * @see #checkIsDirectory(File)
 */
private static void checkExistsAndDirectory(final File dir) throws IOException {
  if (dir.exists()) {
    checkIsDirectory(dir);
  }
}

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

/**
 * Creates single directory.
 *
 * @throws IOException if cannot create directory.
 */
public static File mkdir(final File dir) throws IOException {
  if (dir.exists()) {
    checkIsDirectory(dir);
    return dir;
  }
  return checkCreateDirectory(dir);
}

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

/**
 * Creates all directories at once.
 *
 * @param dirs Directories to make.
 * @throws IOException if cannot create directory.
 */
public static File mkdirs(final File dirs) throws IOException {
  if (dirs.exists()) {
    checkIsDirectory(dirs);
    return dirs;
  }
  return checkCreateDirectory(dirs);
}

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

/**
 * Checks that srcDir exists, that it is a directory and if srcDir and destDir are not equal.
 *
 * @param srcDir  Source directory
 * @param destDir Destination directory
 * @throws IOException if any of the above conditions are not true.
 */
private static void checkDirCopy(final File srcDir, final File destDir) throws IOException {
  checkExists(srcDir);
  checkIsDirectory(srcDir);
  if (equals(srcDir, destDir)) {
    throw new IOException("Source '" + srcDir + "' and destination '" + destDir + "' are equal");
  }
}

代码示例来源: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

checkIsDirectory(destDir);
} else {
  checkCreateDirectory(destDir);

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

/**
 * Checks if directory exists. Throws IOException if it does not.
 *
 * @param dir Directory
 * @throws IOException if directory does not exist.
 * @see #checkIsDirectory(File)
 */
private static void checkExistsAndDirectory(final File dir) throws IOException {
  if (dir.exists()) {
    checkIsDirectory(dir);
  }
}

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

/**
 * Creates single directory.
 *
 * @throws IOException if cannot create directory.
 */
public static File mkdir(final File dir) throws IOException {
  if (dir.exists()) {
    checkIsDirectory(dir);
    return dir;
  }
  return checkCreateDirectory(dir);
}

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

/**
 * Creates all directories at once.
 *
 * @param dirs Directories to make.
 * @throws IOException if cannot create directory.
 */
public static File mkdirs(final File dirs) throws IOException {
  if (dirs.exists()) {
    checkIsDirectory(dirs);
    return dirs;
  }
  return checkCreateDirectory(dirs);
}

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

/**
 * Checks that srcDir exists, that it is a directory and if srcDir and destDir are not equal.
 *
 * @param srcDir  Source directory
 * @param destDir Destination directory
 * @throws IOException if any of the above conditions are not true.
 */
private static void checkDirCopy(final File srcDir, final File destDir) throws IOException {
  checkExists(srcDir);
  checkIsDirectory(srcDir);
  if (equals(srcDir, destDir)) {
    throw new IOException("Source '" + srcDir + "' and destination '" + destDir + "' are equal");
  }
}

代码示例来源: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);
  }
}

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

/**
 * 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: org.jodd/jodd-core

checkIsDirectory(destDir);
} else {
  checkCreateDirectory(destDir);

相关文章