org.uberfire.java.nio.file.Files.copy()方法的使用及代码示例

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

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

Files.copy介绍

暂无

代码示例

代码示例来源:origin: kiegroup/appformer

@Override
public long copy(final Path source,
         final OutputStream out)
    throws IOException, SecurityException {
  return Files.copy(source,
           out);
}

代码示例来源:origin: kiegroup/appformer

@Override
public long copy(final InputStream in,
         final Path target,
         final CopyOption... options)
    throws IOException, FileAlreadyExistsException, DirectoryNotEmptyException, UnsupportedOperationException, SecurityException {
  return Files.copy(in,
           target,
           options);
}

代码示例来源:origin: kiegroup/appformer

@Override
public Path copy(final Path source,
         final Path target,
         final CopyOption... options)
    throws UnsupportedOperationException, FileAlreadyExistsException,
    DirectoryNotEmptyException, IOException, SecurityException {
  return Files.copy(source,
           target,
           options);
}

代码示例来源:origin: kiegroup/appformer

@Override
    public FileVisitResult preVisitDirectory(final org.uberfire.java.nio.file.Path src,
                         final BasicFileAttributes attrs) {
      final org.uberfire.java.nio.file.Path tgt = target.resolve(source.relativize(src));
      try {
        Files.copy(src,
              tgt,
              StandardCopyOption.REPLACE_EXISTING);
//            } catch (FileAlreadyExistsException x) {
      } catch (Exception x) {
        x.printStackTrace();
        //Swallow
      }
      return FileVisitResult.CONTINUE;
    }

代码示例来源:origin: kiegroup/appformer

@Test
public void copyPath2OutInvalidOption() {
  assertThatThrownBy(() -> Files.copy(null, null))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Parameter named 'source' should be not null!");
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyNull3() {
  assertThatThrownBy(() -> Files.copy((Path) null, (Path) null))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Parameter named 'source' should be not null!");
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyNull2() {
  assertThatThrownBy(() -> Files.copy((Path) null, Paths.get("/temp")))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Parameter named 'source' should be not null!");
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyNull1() {
  assertThatThrownBy(() -> Files.copy(newTempDir(), (Path) null))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Parameter named 'target' should be not null!");
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyPath2OutNull2() {
  assertThatThrownBy(() -> Files.copy(Files.createTempFile("foo",
                               "bar"),
                    null))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Parameter named 'out' should be not null!");
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyIn2PathNull1() {
  assertThatThrownBy(() -> Files.copy((InputStream) null,
                    newTempDir().resolve("my_new_file.txt"),
                    REPLACE_EXISTING))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Parameter named 'in' should be not null!");
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyIn2PathNull2() {
  assertThatThrownBy(() -> Files.copy(Files.newInputStream(Files.createTempFile("foo",
                                         "bar")),
                    null,
                    REPLACE_EXISTING))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Parameter named 'target' should be not null!");
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyPath2OutNull1() {
  assertThatThrownBy(() -> {
    try (OutputStream os = Files.newOutputStream(newTempDir().resolve("my_new_file.txt"))) {
      Files.copy(null, os);
    }
  })
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Parameter named 'source' should be not null!");
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyIn2PathNull4() {
  assertThatThrownBy(() -> Files.copy(Files.newInputStream(Files.createTempFile("foo",
                                         "bar")),
                    newTempDir().resolve("my_new_file.txt"),
                    new CopyOption[]{null}))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Parameter named 'opt' should be not null!");
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyDirDirectoryNotEmptyException() {
  final Path source = newTempDir();
  final Path dest = newDirToClean();
  Files.createTempFile(source, "foo", "bar");
  assertThatThrownBy(() -> Files.copy(source, dest))
      .isInstanceOf(DirectoryNotEmptyException.class);
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyIn2PathNull3() {
  assertThatThrownBy(() -> Files.copy(Files.newInputStream(Files.createTempFile("foo",
                                         "bar")),
                    newTempDir().resolve("my_new_file.txt"),
                    null))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Parameter named 'options' should be not null!");
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyIn2PathInvalidOption() {
  assertThatThrownBy(() -> Files.copy(Files.newInputStream(Files.createTempFile("foo",
                                         "bar")),
                    newTempDir().resolve("my_new_file.txt"),
                    NOFOLLOW_LINKS))
      .isInstanceOf(UnsupportedOperationException.class)
      .hasMessage("NOFOLLOW_LINKS not supported");
}

代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend

@After
public void tearDown() {
  Files.delete(path);
  Files.copy(pathCopy, path);
  Files.delete(pathCopy);
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyPath2OutNotExists() {
  assertThatThrownBy(() -> {
    try (OutputStream os = Files.newOutputStream(newTempDir().resolve("my_new_file.txt"))) {
      Files.copy(newTempDir().resolve("myfile.txt"), os);
    }
  }).isInstanceOf(NoSuchFileException.class);
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyFile() throws IOException {
  final Path dir = newTempDir();
  final Path source = dir.resolve("temp.txt");
  final Path dest = dir.resolve("result.txt");
  try (final OutputStream stream = Files.newOutputStream(source)) {
    stream.write('a');
  }
  Files.copy(source,
        dest);
  assertThat(dest.toFile()).exists();
  assertThat(source.toFile()).exists();
  assertThat(dest.toFile().length()).isEqualTo(source.toFile().length());
}

代码示例来源:origin: kiegroup/appformer

@Test
public void copyDir() {
  final Path source = newTempDir();
  final Path dest = newDirToClean();
  assertThat(source.toFile()).exists();
  assertThat(dest.toFile()).doesNotExist();
  Files.copy(source,
        dest);
  assertThat(dest.toFile()).exists();
  assertThat(source.toFile()).exists();
}

相关文章