Class NioFileUtil


  • public final class NioFileUtil
    extends Object
    File-related utilities which use NIO.2 and thus require Java 1.7+.
    See Also:
    FileUtil
    • Method Detail

      • getCanonicalFile

        @NotNull
        public static File getCanonicalFile​(@NotNull
                                            File file,
                                            @NotNull
                                            LinkOption... options)
                                     throws IOException
        Returns the canonical form of the pathname.
        Parameters:
        file - the pathname to get canonical representation of.
        options - options indicating how symbolic links are handled.
        Returns:
        the canonical pathname denoting the same file or directory as file.
        Throws:
        IOException - if an I/O error occurs (i. e. if the link exists and some of the filesystem queries fail).
        See Also:
        Path.toRealPath(LinkOption...), File.getCanonicalFile()
      • getCanonicalFile

        @NotNull
        public static Path getCanonicalFile​(@NotNull
                                            Path path,
                                            @NotNull
                                            LinkOption... options)
                                     throws IOException
        Returns the canonical form of the pathname.
        Parameters:
        path - the pathname to get canonical representation of.
        options - options indicating how symbolic links are handled.
        Returns:
        the canonical pathname denoting the same file or directory as path.
        Throws:
        IOException - if an I/O error occurs (i. e. if the link exists and some of the filesystem queries fail).
        See Also:
        Path.toRealPath(LinkOption...), File.getCanonicalFile()
      • deleteRecursively

        public static void deleteRecursively​(@NotNull
                                             Path path)
                                      throws IOException
        Deletes the directory recursively.
        Parameters:
        path - the directory to delete.
        Throws:
        IOException - if an I/O error occurs.
      • deleteRecursively

        public static void deleteRecursively​(@NotNull
                                             Path path,
                                             @NotNull
                                             Set<Path> excludes)
                                      throws IOException
        Deletes the directory recursively.
        Parameters:
        path - the directory to delete.
        excludes - the set of basenames (denoting either files or directories) to be preserved when deleting.
        Throws:
        IOException - if an I/O error occurs.