fge*_*fge 24
不确定你想要什么,但例如:
try {
Files.createFile(thePath);
} catch (FileAlreadyExistsException ignored) {
}
Run Code Online (Sandbox Code Playgroud)
还有其他解决方案; 例如:
if (!Files.exists(thePath, LinkOption.NOFOLLOW_LINKS))
Files.createFile(thePath);
Run Code Online (Sandbox Code Playgroud)
请注意,与File文件创建失败一样,这些将抛出异常!而相关的多个在那(例如AccessDeniedException,ReadOnlyFileSystemException,等等等等)
有关更多信息,请参见此处 另请参阅为什么要java.nio.file快速迁移到.
| 归档时间: |
|
| 查看次数: |
20210 次 |
| 最近记录: |