cn.hutool.core.io.FileUtil.equals()方法的使用及代码示例

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

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

FileUtil.equals介绍

[英]检查两个文件是否是同一个文件
所谓文件相同,是指File对象是否指向同一个文件或文件夹
[中]检查两个文件是否是同一个文件
所谓文件相同,是指文件对象是否指向同一个文件或文件夹

代码示例

代码示例来源:origin: looly/hutool

/**
 * 通过JDK7+的 {@link Files#copy(Path, Path, CopyOption...)} 方法拷贝文件
 * 
 * @param src 源文件
 * @param dest 目标文件或目录,如果为目录使用与源文件相同的文件名
 * @param options {@link StandardCopyOption}
 * @return 目标文件
 * @throws IORuntimeException IO异常
 */
public static File copyFile(File src, File dest, StandardCopyOption... options) throws IORuntimeException {
  // check
  Assert.notNull(src, "Source File is null !");
  if (false == src.exists()) {
    throw new IORuntimeException("File not exist: " + src);
  }
  Assert.notNull(dest, "Destination File or directiory is null !");
  if (equals(src, dest)) {
    throw new IORuntimeException("Files '{}' and '{}' are equal", src, dest);
  }
  return copyFile(src.toPath(), dest.toPath(), options).toFile();
}

代码示例来源:origin: looly/hutool

/**
 * 通过JDK7+的 {@link Files#copy(Path, Path, CopyOption...)} 方法拷贝文件
 * 
 * @param src 源文件
 * @param dest 目标文件或目录,如果为目录使用与源文件相同的文件名
 * @param options {@link StandardCopyOption}
 * @return 目标文件
 * @throws IORuntimeException IO异常
 */
public static File copyFile(File src, File dest, StandardCopyOption... options) throws IORuntimeException {
  // check
  Assert.notNull(src, "Source File is null !");
  if (false == src.exists()) {
    throw new IORuntimeException("File not exist: " + src);
  }
  Assert.notNull(dest, "Destination File or directiory is null !");
  if (equals(src, dest)) {
    throw new IORuntimeException("Files '{}' and '{}' are equal", src, dest);
  }
  return copyFile(src.toPath(), dest.toPath(), options).toFile();
}

代码示例来源:origin: looly/hutool

if (equals(file1, file2)) {

代码示例来源:origin: looly/hutool

if (equals(file1, file2)) {

代码示例来源:origin: looly/hutool

if (equals(file1, file2)) {

代码示例来源:origin: looly/hutool

if (equals(file1, file2)) {

代码示例来源:origin: looly/hutool

if (FileUtil.equals(src, dest)) {
  throw new IORuntimeException("Files '{}' and '{}' are equal", src, dest);

代码示例来源:origin: looly/hutool

if (FileUtil.equals(src, dest)) {
  throw new IORuntimeException("Files '{}' and '{}' are equal", src, dest);

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 通过JDK7+的 {@link Files#copy(Path, Path, CopyOption...)} 方法拷贝文件
 * 
 * @param src 源文件
 * @param dest 目标文件或目录,如果为目录使用与源文件相同的文件名
 * @param options {@link StandardCopyOption}
 * @return 目标文件
 * @throws IORuntimeException IO异常
 */
public static File copyFile(File src, File dest, StandardCopyOption... options) throws IORuntimeException {
  // check
  Assert.notNull(src, "Source File is null !");
  if (false == src.exists()) {
    throw new IORuntimeException("File not exist: " + src);
  }
  Assert.notNull(dest, "Destination File or directiory is null !");
  if (equals(src, dest)) {
    throw new IORuntimeException("Files '{}' and '{}' are equal", src, dest);
  }
  return copyFile(src.toPath(), dest.toPath(), options).toFile();
}

代码示例来源:origin: cn.hutool/hutool-all

if (equals(file1, file2)) {

代码示例来源:origin: cn.hutool/hutool-all

if (equals(file1, file2)) {

代码示例来源:origin: cn.hutool/hutool-all

if (FileUtil.equals(src, dest)) {
  throw new IORuntimeException("Files '{}' and '{}' are equal", src, dest);

相关文章

微信公众号

最新文章

更多