本文整理了Java中org.uberfire.java.nio.file.Files.move()
方法的一些代码示例,展示了Files.move()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Files.move()
方法的具体详情如下:
包路径:org.uberfire.java.nio.file.Files
类名称:Files
方法名:move
暂无
代码示例来源:origin: kiegroup/appformer
@Override
public Path move(final Path source,
final Path target,
final CopyOption... options)
throws UnsupportedOperationException, FileAlreadyExistsException,
DirectoryNotEmptyException, AtomicMoveNotSupportedException, IOException, SecurityException {
return Files.move(source,
target,
options);
}
代码示例来源:origin: kiegroup/appformer
@Test
public void moveNull3() {
assertThatThrownBy(() -> Files.move(null, null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Parameter named 'source' should be not null!");
}
代码示例来源:origin: kiegroup/appformer
@Test
public void moveNull1() {
assertThatThrownBy(() -> Files.move(newTempDir(), null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Parameter named 'target' should be not null!");
}
代码示例来源:origin: kiegroup/appformer
@Test
public void moveNull2() {
assertThatThrownBy(() -> Files.move(null, newTempDir()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Parameter named 'source' should be not null!");
}
代码示例来源:origin: kiegroup/appformer
@Override
public Path move(final Path source,
final Path target,
final CopyOption... options)
throws UnsupportedOperationException, FileAlreadyExistsException,
DirectoryNotEmptyException, AtomicMoveNotSupportedException, IOException, SecurityException {
if (Files.exists(dot(source))) {
Files.move(dot(source),
dot(target),
forceBuildOptions(options));
} else if (Files.exists(dot(target))) {
Files.delete(dot(target));
}
final Path result = Files.move(source,
target,
options);
return result;
}
代码示例来源:origin: kiegroup/appformer
@Test
public void moveFileInvalidSourceAndTarget() throws IOException {
final Path source = newTempDir();
final Path dest = newTempDir().resolve("other");
final Path sourceFile = source.resolve("file.txt");
try (final OutputStream stream = Files.newOutputStream(sourceFile)) {
stream.write('a');
}
assertThatThrownBy(() -> Files.move(source, dest))
.isInstanceOf(DirectoryNotEmptyException.class);
sourceFile.toFile().delete();
Files.copy(source,
dest);
assertThatThrownBy(() -> Files.move(source, dest))
.isInstanceOf(FileAlreadyExistsException.class);
dest.toFile().delete();
source.toFile().delete();
assertThatThrownBy(() -> Files.move(source, dest))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Condition 'source must exist' is invalid!");
}
代码示例来源:origin: kiegroup/appformer
@Test
public void moveFile() throws IOException {
final Path dir = newTempDir();
final Path source = dir.resolve("fileSource.txt");
final Path dest = dir.resolve("fileDest.txt");
try (final OutputStream stream = Files.newOutputStream(source)) {
stream.write('a');
}
long lenght = source.toFile().length();
Files.move(source,
dest);
assertThat(dest.toFile()).exists();
assertThat(source.toFile()).doesNotExist();
assertThat(dest.toFile().length()).isEqualTo(lenght);
}
代码示例来源:origin: kiegroup/appformer
@Test
public void moveDir() {
final Path source = newTempDir();
final Path dest = newTempDir().resolve("other");
Files.move(source,
dest);
assertThat(source.toFile()).doesNotExist();
assertThat(dest.toFile()).exists();
}
内容来源于网络,如有侵权,请联系作者删除!