Files Utility Class Flashcards
Creates a file given by the dirPath, and sets the attributes given by dirAttributes. Creates intermediate directories if they do not exist.
Path createDirectories(Path dir, FileAttribute> attrs)
Creates a file given by the dirPath, and sets the attributes given by dirAttributes. Does not create intermediate directories if they do not exist
Path createDirectory(Path dir, FileAttribute> attrs)
Creates a temporary file with the given prefix, suffix, and attributes in the directory given by dir.
Path createTempFile(Path dir, String prefix, String suffix, FileAttribute> … attrs)
Creates a temporary directory with the given prefix, directory attributes in the path specified by dir.
Path createTempDirectory(Path dir, String prefix, FileAttribute> … attrs)
Copy the file from source to target. CopyOption could be REPLACE_EXISTING, COPY_ATTRIBUTES, OR NOFOLLOW_LINKS. Can throw FileAlreadyExistsException.
Path copy(Path source, Path target, CopyOption… options)
Similar to the coy operation except that the source file is removed. If the source and target are in the same directory, it is effectively file rename.
Path move(Path source, Path target, CopyOption… options)
Checks if the two Path objects locate the same file or not.
boolean isSameFile(Path path, Path path2)
Checks if a file/directory exists in the given path; can specify LinkOption.NOFOLLOW_LINKS to not follow symbolic links.
boolean exists(Path path, LinkOption … option)
Returns true if the file represented by path is a regular file.
Boolean isRegularFile(Path path, LinkOption …)
Returns true if the file presented by path is a symbolic link.
Boolean isSymbolicLink(Path path)
Returns true if the file represented by path is a hidden file.
Boolean isHidden(Path path)
Returns the size of the file in bytes represented by the path.
long size(Path path)
Gets the owner of the file.
UserPrincipal getOwner(Path path, LinkOption…)
Sets the owner of the file.
Path setOwner(Path path, UserPrincipal owner)
Gets the last modified time for the specified time.
FileTime getLastModifiedTime(Path path, LinkOption….)