Files Utility Class Flashcards Preview

OCP > Files Utility Class > Flashcards

Flashcards in Files Utility Class Deck (19):
1

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)

2

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)

3

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)

4

Creates a temporary directory with the given prefix, directory attributes in the path specified by dir.

Path createTempDirectory(Path dir, String prefix, FileAttribute> ... attrs)

5

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)

6

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)

7

Checks if the two Path objects locate the same file or not.

boolean isSameFile(Path path, Path path2)

8

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)

9

Returns true if the file represented by path is a regular file.

Boolean isRegularFile(Path path, LinkOption ...)

10

Returns true if the file presented by path is a symbolic link.

Boolean isSymbolicLink(Path path)

11

Returns true if the file represented by path is a hidden file.

Boolean isHidden(Path path)

12

Returns the size of the file in bytes represented by the path.

long size(Path path)

13

Gets the owner of the file.

UserPrincipal getOwner(Path path, LinkOption...)

14

Sets the owner of the file.

Path setOwner(Path path, UserPrincipal owner)

15

Gets the last modified time for the specified time.

FileTime getLastModifiedTime(Path path, LinkOption....)

16

Sets the last modified time for the specified time.

Path setLastModifiedTime(Path path, FileTime time)

17

Gets the specified attribute of the specified file.

Object getAttribute(Path path, String attribute, LinkOption...)

18

Sets the specified attribute of the specified file.

Path setAttribute(Path path, String attribute, Object value, LinkOption ....)

19

Returns true if directory, false if file.

boolean isDirectory(Path path, LinkOption....)