Files Utility Class Flashcards

1
Q

Creates a file given by the dirPath, and sets the attributes given by dirAttributes. Creates intermediate directories if they do not exist.

A

Path createDirectories(Path dir, FileAttribute> attrs)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Creates a file given by the dirPath, and sets the attributes given by dirAttributes. Does not create intermediate directories if they do not exist

A

Path createDirectory(Path dir, FileAttribute> attrs)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Creates a temporary file with the given prefix, suffix, and attributes in the directory given by dir.

A

Path createTempFile(Path dir, String prefix, String suffix, FileAttribute> … attrs)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Copy the file from source to target. CopyOption could be REPLACE_EXISTING, COPY_ATTRIBUTES, OR NOFOLLOW_LINKS. Can throw FileAlreadyExistsException.

A

Path copy(Path source, Path target, CopyOption… options)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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.

A

Path move(Path source, Path target, CopyOption… options)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

boolean isSameFile(Path path, Path path2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Checks if a file/directory exists in the given path; can specify LinkOption.NOFOLLOW_LINKS to not follow symbolic links.

A

boolean exists(Path path, LinkOption … option)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

Boolean isRegularFile(Path path, LinkOption …)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

Boolean isSymbolicLink(Path path)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

Boolean isHidden(Path path)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

long size(Path path)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Gets the owner of the file.

A

UserPrincipal getOwner(Path path, LinkOption…)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Sets the owner of the file.

A

Path setOwner(Path path, UserPrincipal owner)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Gets the last modified time for the specified time.

A

FileTime getLastModifiedTime(Path path, LinkOption….)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Sets the last modified time for the specified time.

A

Path setLastModifiedTime(Path path, FileTime time)

17
Q

Gets the specified attribute of the specified file.

A

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

18
Q

Sets the specified attribute of the specified file.

A

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

19
Q

Returns true if directory, false if file.

A

boolean isDirectory(Path path, LinkOption….)