java.nio.file.AccessDeniedException.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(125)

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

AccessDeniedException.<init>介绍

暂无

代码示例

代码示例来源:origin: eirslett/frontend-maven-plugin

private void prepDestination(File path, boolean directory) throws IOException {
  if (directory) {
    path.mkdirs();
  } else {
    if (!path.getParentFile().exists()) {
      path.getParentFile().mkdirs();
    }
    if(!path.getParentFile().canWrite()) {
      throw new AccessDeniedException(
          String.format("Could not get write permissions for '%s'", path.getParentFile().getAbsolutePath()));
    }
  }
}

代码示例来源:origin: org.apache.lucene/lucene-core

public IndexInput openInput() throws IOException {
 IndexInput local = this.content;
 if (local == null) {
  throw new AccessDeniedException("Can't open a file still open for writing: " + fileName);
 }
 return local.clone();
}

代码示例来源:origin: KronicDeth/intellij-elixir

@NotNull
  public static String exeFileToExePath(@NotNull File file) throws FileNotFoundException, AccessDeniedException {
    String path;

    if (file.exists()) {
      if (file.canExecute()) {
        path = file.getAbsolutePath();
      } else {
        throw new AccessDeniedException(file.getAbsolutePath(), null, " is not executable");
      }
    } else {
      throw new FileNotFoundException(file.getAbsolutePath() + " does not exist");
    }

    return path;
  }
}

代码示例来源:origin: neo4j/neo4j

public static void checkWritableDirectory( Path directory ) throws FileSystemException
{
  if ( !exists( directory ) )
  {
    throw new NoSuchFileException( directory.toString() );
  }
  if ( isRegularFile( directory ) )
  {
    throw new FileSystemException( directory.toString() + ": Not a directory" );
  }
  if ( !isWritable( directory ) )
  {
    throw new AccessDeniedException( directory.toString() );
  }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * A wrapper for {@link File#list()}. This java.io API returns null
 * when a dir is not a directory or for any I/O error. Instead of having
 * null check everywhere File#list() is used, we will add utility API
 * to get around this problem. For the majority of cases where we prefer
 * an IOException to be thrown.
 * @param dir directory for which listing should be performed
 * @return list of file names or empty string list
 * @exception AccessDeniedException for unreadable directory
 * @exception IOException for invalid directory or for bad disk
 */
public static String[] list(File dir) throws IOException {
 if (!canRead(dir)) {
  throw new AccessDeniedException(dir.toString(), null,
    FSExceptionMessages.PERMISSION_DENIED);
 }
 String[] fileNames = dir.list();
 if(fileNames == null) {
  throw new IOException("Invalid directory or I/O error occurred for dir: "
       + dir.toString());
 }
 return fileNames;
}

代码示例来源:origin: Graylog2/graylog2-server

final AccessDeniedException accessDeniedException = new AccessDeniedException(committedReadOffsetFile.getAbsolutePath(), null, e.getMessage());
throw new RuntimeException(accessDeniedException);

代码示例来源:origin: org.eclipse.jetty/jetty-client

public PathContentProvider(String contentType, Path filePath, int bufferSize) throws IOException
{
  super(contentType);
  if (!Files.isRegularFile(filePath))
    throw new NoSuchFileException(filePath.toString());
  if (!Files.isReadable(filePath))
    throw new AccessDeniedException(filePath.toString());
  this.filePath = filePath;
  this.fileSize = Files.size(filePath);
  this.bufferSize = bufferSize;
}

代码示例来源:origin: JakeWharton/resourcefs

@Override public void checkAccess(Path path, AccessMode... modes) throws IOException {
 for (AccessMode mode : modes) {
  if (mode == AccessMode.WRITE) {
   throw readOnly();
  } else if (mode == AccessMode.EXECUTE) {
   throw new AccessDeniedException("Resources are not executable.");
  }
 }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

public IndexInput openInput() throws IOException {
 IndexInput local = this.content;
 if (local == null) {
  throw new AccessDeniedException("Can't open a file still open for writing: " + fileName);
 }
 return local.clone();
}

代码示例来源:origin: com.github.marschall/memoryfilesystem

void assertOwner() throws AccessDeniedException {
 UserPrincipal user = this.attributes.getCurrentUser();
 if (!this.getOwner().equals(user)) {
  throw new AccessDeniedException(this.path.toString());
 }
}

代码示例来源:origin: usethesource/rascal

@Override
public void mkDirectory(ISourceLocation uri) throws IOException {
  if (uri.getScheme().endsWith("+readonly")) {
    throw new AccessDeniedException(uri.toString());
  }
}

代码示例来源:origin: hypercube1024/firefly

public PathContentProvider(String contentType, Path filePath, int bufferSize) throws IOException {
  super(contentType);
  if (!Files.isRegularFile(filePath))
    throw new NoSuchFileException(filePath.toString());
  if (!Files.isReadable(filePath))
    throw new AccessDeniedException(filePath.toString());
  this.filePath = filePath;
  this.fileSize = Files.size(filePath);
  this.bufferSize = bufferSize;
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

public PathContentProvider(Path filePath, int bufferSize) throws IOException
{
  if (!Files.isRegularFile(filePath))
    throw new NoSuchFileException(filePath.toString());
  if (!Files.isReadable(filePath))
    throw new AccessDeniedException(filePath.toString());
  this.filePath = filePath;
  this.fileSize = Files.size(filePath);
  this.bufferSize = bufferSize;
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

public PathContentProvider(Path filePath, int bufferSize) throws IOException
{
  if (!Files.isRegularFile(filePath))
    throw new NoSuchFileException(filePath.toString());
  if (!Files.isReadable(filePath))
    throw new AccessDeniedException(filePath.toString());
  this.filePath = filePath;
  this.fileSize = Files.size(filePath);
  this.bufferSize = bufferSize;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

break;
case 5:
  exception = new AccessDeniedException(file, other, reason);
  break;
case 6:

代码示例来源:origin: org.xbib/sshd-common

public LocalFileScpTargetStreamResolver(Path path, ScpFileOpener opener) throws IOException {
  LinkOption[] linkOptions = IoUtils.getLinkOptions(true);
  this.status = IoUtils.checkFileExists(path, linkOptions);
  if (status == null) {
    throw new AccessDeniedException("Receive target file path existence status cannot be determined: " + path);
  }
  this.path = path;
  this.opener = (opener == null) ? DefaultScpFileOpener.INSTANCE : opener;
}

代码示例来源:origin: com.beijunyi/parallelgit-filesystem

@Nonnull
private static FileNode asFile(@Nullable Node node, GitPath path) throws NoSuchFileException, AccessDeniedException {
 if(node == null) throw new NoSuchFileException(path.toString());
 if(node instanceof FileNode) return (FileNode) node;
 throw new AccessDeniedException(path.toString());
}

代码示例来源:origin: usethesource/rascal

@Override
  public void remove(ISourceLocation uri) throws IOException {
    if (uri.getScheme().endsWith("+readonly")) {
      throw new AccessDeniedException(uri.toString());
    }
    
    fileSystem.getFileSystem().remove(uri.getPath());
  }
}

代码示例来源:origin: com.beijunyi/parallelgit-filesystem

public static boolean copy(GitPath source, GitPath target, Set<CopyOption> options) throws IOException {
 Node sourceNode = getNode(source);
 if(source.equals(target)) return false;
 if(target.isRoot()) throw new AccessDeniedException(target.toString());
 GitPath targetParent = getParent(target);
 DirectoryNode targetDirectory = findDirectory(targetParent);
 Node targetNode = sourceNode.clone(targetDirectory);
 if(!targetDirectory.addChild(getFileName(target), targetNode, options.contains(REPLACE_EXISTING)))
  throw new FileAlreadyExistsException(target.toString());
 return true;
}

代码示例来源:origin: beijunyi/ParallelGit

public static void delete(GitPath file) throws IOException {
 if(file.isRoot()) throw new AccessDeniedException(file.toString());
 GitPath parentPath = getParent(file);
 Node parent = findNode(getParent(file));
 if(parent == null || !parent.isDirectory() || !asDirectory(parent, parentPath).removeChild(getFileName(file)))
  throw new NoSuchFileException(file.toString());
}

相关文章