Package java.nio.file

Examples of java.nio.file.FileSystemException


    try {
      DirectoryEntry entry = lookUp(path, options);
      if (entry.exists()) {
        File file = entry.file();
        if (!file.isRegularFile()) {
          throw new FileSystemException(path.toString(), null, "not a regular file");
        }
        return open((RegularFile) file, options);
      } else {
        return null;
      }
View Full Code Here


    store.writeLock().lock();
    try {
      File file = createFile(path, store.regularFileCreator(), options.contains(CREATE_NEW), attrs);
      // the file already existed but was not a regular file
      if (!file.isRegularFile()) {
        throw new FileSystemException(path.toString(), null, "not a regular file");
      }
      return open((RegularFile) file, options);
    } finally {
      store.writeLock().unlock();
    }
View Full Code Here

    if (!store.supportsFeature(Feature.LINKS)) {
      throw new UnsupportedOperationException();
    }

    if (!isSameFileSystem(existingView)) {
      throw new FileSystemException(link.toString(), existing.toString(),
          "can't link: source and target are in different file system instances");
    }

    Name linkName = link.name();

    // existingView is in the same file system, so just one lock is needed
    store.writeLock().lock();
    try {
      // we do want to follow links when finding the existing file
      File existingFile = existingView.lookUp(existing, Options.FOLLOW_LINKS)
          .requireExists(existing)
          .file();
      if (!existingFile.isRegularFile()) {
        throw new FileSystemException(link.toString(), existing.toString(),
            "can't link: not a regular file");
      }

      Directory linkParent = lookUp(link, Options.NOFOLLOW_LINKS)
          .requireDoesNotExist(link)
View Full Code Here

   * Checks that the given file can be deleted, throwing an exception if it can't.
   */
  private void checkDeletable(
      File file, DeleteMode mode, Path path) throws IOException {
    if (file.isRootDirectory()) {
      throw new FileSystemException(
          path.toString(), null, "can't delete root directory");
    }

    if (file.isDirectory()) {
      if (mode == DeleteMode.NON_DIRECTORY_ONLY) {
        throw new FileSystemException(
            path.toString(), null, "can't delete: is a directory");
      }

      checkEmpty(((Directory) file), path);
    } else if (mode == DeleteMode.DIRECTORY_ONLY) {
      throw new FileSystemException(
          path.toString(), null, "can't delete: is not a directory");
    }

    if (file == workingDirectory && !path.isAbsolute()) {
      // this is weird, but on Unix at least, the file system seems to be happy to delete the
      // working directory if you give the absolute path to it but fail if you use a relative path
      // that resolves to the working directory (e.g. "" or ".")
      throw new FileSystemException(path.toString(), null, "invalid argument");
    }
  }
View Full Code Here

    }
  }

  private void checkMovable(File file, JimfsPath path) throws FileSystemException {
    if (file.isRootDirectory()) {
      throw new FileSystemException(path.toString(), null, "can't move root directory");
    }
  }
View Full Code Here

        public void methodThrowExceptions() throws CharConversionException, FileSystemException, IOException {
            int i = (int) (Math.random() * 3);
            if (i == 0)
                throw new CharConversionException();
            if (i == 1)
                throw new FileSystemException("");
            if (i == 2)
                throw new IOException();
        }
View Full Code Here

        final File destDir = new File("src/test/resources/");
        destDir.mkdir();

        final boolean isMoved = fileToMove.renameTo(new File("src/test/resources/movedFile_jdk6.txt"));
        if (!isMoved) {
            throw new FileSystemException("src/test/resources/movedFile_jdk6.txt");
        }
    }
View Full Code Here

TOP

Related Classes of java.nio.file.FileSystemException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.