本文整理汇总了Java中java.nio.file.NotLinkException类的典型用法代码示例。如果您正苦于以下问题:Java NotLinkException类的具体用法?Java NotLinkException怎么用?Java NotLinkException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NotLinkException类属于java.nio.file包,在下文中一共展示了NotLinkException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translateOrThrow
import java.nio.file.NotLinkException; //导入依赖的package包/类
protected final int translateOrThrow(Exception exception) {
return ExceptionTranslator.<Integer, Exception> of(exception) //
.translate(AccessDeniedException.class, e -> -ErrorCodes.EPERM()) //
.translate(NoSuchFileException.class, e -> -ErrorCodes.ENOENT()) //
.translate(NotDirectoryException.class, e -> -ErrorCodes.ENOTDIR()) //
.translate(NotLinkException.class, e -> -ErrorCodes.EINVAL()) //
.translate(UnsupportedOperationException.class, e -> -ErrorCodes.ENOSYS()) //
.translate(IOException.class, e -> {
logger.warn("", e); // Unmapped IOException, log warning
return -ErrorCodes.EIO();
}).get();
}
示例2: testAllErrors
import java.nio.file.NotLinkException; //导入依赖的package包/类
protected void testAllErrors(Try.CheckedConsumer<ExpectedResult, Exception> sut)
throws Exception {
List<ExpectedResult> list = list( //
exp(new NoSuchFileException(null), -ErrorCodes.ENOENT()), //
exp(new AccessDeniedException(null), -ErrorCodes.EPERM()), //
exp(new NotDirectoryException(null), -ErrorCodes.ENOTDIR()), //
exp(new NotLinkException(null), -ErrorCodes.EINVAL()), //
exp(new UnsupportedOperationException(), -ErrorCodes.ENOSYS()), //
exp(new IOException(), -ErrorCodes.EIO())); //
list.forEach(expected -> Try.runWithCatch(() -> sut.accept(expected), Exception.class).get());
}
示例3: readSymbolicLink
import java.nio.file.NotLinkException; //导入依赖的package包/类
@Override
public File readSymbolicLink(File link) throws IOException {
if (!isSymbolicLink(link)) {
throw new NotLinkException(link.getPath());
}
VirtualFile vf = fileSystem.findFile(link.getPath());
return VfsUtil.virtualToIoFile(symlinks.get(vf));
}
示例4: getRawSymbolicLink
import java.nio.file.NotLinkException; //导入依赖的package包/类
public EphemeralFsPath getRawSymbolicLink(Path parent, EphemeralFsPath fileName) throws FileSystemException {
DirectoryEntry entry = children.get(fileName.toFileName());
if(entry == null) {
throw new NoSuchFileException(parent.resolve(fileName).toString());
}
if(!entry.isSymbolicLink()) {
throw new NotLinkException(parent.resolve(fileName).toString());
}
return entry.getSymbolicLink();
}
示例5: testReadSymbolicLinkNoSymbolicLink
import java.nio.file.NotLinkException; //导入依赖的package包/类
@Test
public void testReadSymbolicLinkNoSymbolicLink() throws Exception {
Path notSymLink = root.resolve("notSymLink");
Files.createDirectories(notSymLink);
try {
Files.readSymbolicLink(notSymLink);
fail();
} catch(NotLinkException e) {
//pass
}
}
示例6: readSymLink
import java.nio.file.NotLinkException; //导入依赖的package包/类
@Override
public Path readSymLink(Path path) throws IOException {
Path target = symLinks.get(path);
if (target == null) {
throw new NotLinkException(path.toString());
}
return target;
}
示例7: requireSymbolicLink
import java.nio.file.NotLinkException; //导入依赖的package包/类
/**
* Checks that this entry exists and links to a symbolic link, throwing an exception if not.
*
* @return this
* @throws NoSuchFileException if this entry does not exist
* @throws NotLinkException if this entry does not link to a symbolic link
*/
public DirectoryEntry requireSymbolicLink(Path pathForException)
throws NoSuchFileException, NotLinkException {
requireExists(pathForException);
if (!file().isSymbolicLink()) {
throw new NotLinkException(pathForException.toString());
}
return this;
}
示例8: testGetSymLinkOfNonLinkThrows
import java.nio.file.NotLinkException; //导入依赖的package包/类
@Test( expected = NotLinkException.class )
@Category( { SymLink.class } )
public void testGetSymLinkOfNonLinkThrows() throws IOException {
Files.readSymbolicLink( targetFile() );
}