本文整理了Java中org.uberfire.java.nio.file.Files.createDirectory()
方法的一些代码示例,展示了Files.createDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Files.createDirectory()
方法的具体详情如下:
包路径:org.uberfire.java.nio.file.Files
类名称:Files
方法名:createDirectory
暂无
代码示例来源:origin: kiegroup/appformer
@Override
public Path createDirectory(final Path dir,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException,
IOException, SecurityException {
return Files.createDirectory(dir,
attrs);
}
代码示例来源:origin: org.uberfire/vfs-api
public static Path createTempDirectory(final Path dir, final String prefix, final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException, IOException, SecurityException {
checkNotNull("dir", dir);
if (notExists(dir)) {
throw new NoSuchFileException(dir.toString());
}
final StringBuilder sb = new StringBuilder();
if (prefix != null && prefix.trim().length() > 0) {
sb.append(prefix).append("-");
}
final String baseName = sb.append(System.currentTimeMillis()).append("-").toString();
for (int counter = 0; counter < TEMP_DIR_ATTEMPTS; counter++) {
final Path path2Create = dir.resolve(baseName + counter);
try {
return createDirectory(path2Create, attrs);
} catch (Exception ex) {
}
}
throw new IllegalStateException("Failed to create directory within "
+ TEMP_DIR_ATTEMPTS + " attempts (tried "
+ baseName + "0 to " + baseName + (TEMP_DIR_ATTEMPTS - 1) + ')');
}
代码示例来源:origin: org.uberfire/uberfire-nio2-api
public static Path createTempDirectory(final Path dir,
final String prefix,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException, IOException, SecurityException {
checkNotNull("dir",
dir);
if (notExists(dir)) {
throw new NoSuchFileException(dir.toString());
}
final StringBuilder sb = new StringBuilder();
if (prefix != null && prefix.trim().length() > 0) {
sb.append(prefix).append("-");
}
final String baseName = sb.append(System.currentTimeMillis()).append("-").toString();
for (int counter = 0; counter < TEMP_DIR_ATTEMPTS; counter++) {
final Path path2Create = dir.resolve(baseName + counter);
try {
return createDirectory(path2Create,
attrs);
} catch (Exception ex) {
}
}
throw new IllegalStateException("Failed to create directory within "
+ TEMP_DIR_ATTEMPTS + " attempts (tried "
+ baseName + "0 to " + baseName + (TEMP_DIR_ATTEMPTS - 1) + ')');
}
代码示例来源:origin: kiegroup/appformer
public static Path createTempDirectory(final Path dir,
final String prefix,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException, IOException, SecurityException {
checkNotNull("dir",
dir);
if (notExists(dir)) {
throw new NoSuchFileException(dir.toString());
}
final StringBuilder sb = new StringBuilder();
if (prefix != null && prefix.trim().length() > 0) {
sb.append(prefix).append("-");
}
final String baseName = sb.append(System.currentTimeMillis()).append("-").toString();
for (int counter = 0; counter < TEMP_DIR_ATTEMPTS; counter++) {
final Path path2Create = dir.resolve(baseName + counter);
try {
return createDirectory(path2Create,
attrs);
} catch (Exception ex) {
}
}
throw new IllegalStateException("Failed to create directory within "
+ TEMP_DIR_ATTEMPTS + " attempts (tried "
+ baseName + "0 to " + baseName + (TEMP_DIR_ATTEMPTS - 1) + ')');
}
代码示例来源:origin: kiegroup/appformer
@Test
public void createDirectoryNull() {
assertThatThrownBy(() -> Files.createDirectory(null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Parameter named 'dir' should be not null!");
}
代码示例来源:origin: kiegroup/appformer
@Test
public void createDirectoryFileAlreadyExists() {
assertThatThrownBy(() -> Files.createDirectory(newTempDir()))
.isInstanceOf(FileAlreadyExistsException.class);
}
代码示例来源:origin: kiegroup/appformer
protected Path internalCreateDirectory(final Path dir,
final boolean skipAlreadyExistsException,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException,
IOException, SecurityException {
checkNotNull("dir",
dir);
FileAttribute<?>[] allAttrs = attrs;
try {
Files.createDirectory(dir,
attrs);
} catch (final FileAlreadyExistsException ex) {
final Properties properties = new Properties();
if (exists(dot(dir))) {
properties.load(newInputStream(dot(dir)));
}
allAttrs = consolidate(properties,
attrs);
if (!skipAlreadyExistsException) {
throw ex;
}
}
buildDotFile(dir,
newOutputStream(dot(dir)),
allAttrs);
return dir;
}
代码示例来源:origin: kiegroup/appformer
@Test
public void createDirectory() {
final Path path = newTempDir();
final Path dir = Files.createDirectory(path.resolve("myNewDir"));
assertThat(dir).isNotNull();
assertThat(dir.toFile()).exists();
assertThat(dir.toFile()).isDirectory();
final Path file = Files.createFile(dir.resolve("new.file.txt"));
assertThat(file).isNotNull();
assertThat(file.toFile()).exists();
assertThat(file.toFile()).isFile();
}
内容来源于网络,如有侵权,请联系作者删除!