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

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

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

FileUtil.move介绍

[英]Smart move. If source is a directory, move it to destination. Otherwise, if destination is directory, move source File to it. Otherwise, try to move source File to destination File.
[中]聪明的举动。如果源是目录,则将其移动到目标。否则,若目标是目录,则将源文件移动到该目录。否则,请尝试将源文件移动到目标文件。

代码示例

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

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

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

public static void move(String src, String dest) throws IOException {
  move(file(src), file(dest), fileUtilParams);
}

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

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

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

/**
 * @see #move(File, File)
 */
public static void move(final String src, final String dest) throws IOException {
  move(file(src), file(dest));
}

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

/**
 * Writes file upload item to destination folder or to destination file.
 * Returns the destination file.
 */
public File write(File destination) throws IOException {
  if (destination.isDirectory()) {
    destination = new File(destination, this.header.getFileName());
  }
  if (data != null) {
    FileUtil.writeBytes(destination,  data);
  } else {
    if (tempFile != null) {
      FileUtil.move(tempFile, destination);
    }
  }
  return destination;
}

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

@Test
void testGzip() throws IOException {
  ZipUtil.gzip(new File(dataRoot, "sb.data"));
  File gzipFile = new File(dataRoot, "sb.data.gz");
  assertTrue(gzipFile.exists());
  FileUtil.move(gzipFile, new File(dataRoot, "sb2.data.gz"));
  ZipUtil.ungzip(new File(dataRoot, "sb2.data.gz"));
  File data = new File(dataRoot, "sb2.data");
  assertTrue(data.exists());
  byte[] data2Bytes = FileUtil.readBytes(data);
  byte[] data1Bytes = FileUtil.readBytes(new File(dataRoot, "sb.data"));
  assertTrue(Arrays.equals(data1Bytes, data2Bytes));
  // cleanup
  FileUtil.delete(new File(dataRoot, "sb2.data"));
  FileUtil.delete(new File(dataRoot, "sb2.data.gz"));
}

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

/**
 * Writes file upload item to destination folder or to destination file.
 * Returns the destination file.
 */
public File write(File destination) throws IOException {
  if (destination.isDirectory()) {
    destination = new File(destination, this.header.getFileName());
  }
  if (data != null) {
    FileUtil.writeBytes(destination,  data);
  } else {
    if (tempFile != null) {
      FileUtil.move(tempFile, destination);
    }
  }
  return destination;
}

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

/**
 * @see #move(File, File)
 */
public static void move(final String src, final String dest) throws IOException {
  move(file(src), file(dest));
}

相关文章

微信公众号

最新文章

更多