Path Interface Flashcards

1
Q

Returns a path object representing the root of the given path, or null if the path does not have a root.

A

Path getRoot()

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

Returns the file name or directory name of the given path. Note that the file/directory name is the last element or name in the given path.

A

Path getFileName()

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

Returns the path object representing the parent of the given path, or null if no parent component exists for the path.

A

Path getParent()

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

Returns the number of file/directory names in the given path; returns 0 if the given path represents the root.

A

int getNameCount()

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

Returns the i^th file/directory name; the index 0 starts from the closest name to the root.

A

Path getName(int index)

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

Returns a path object that is part of this path object; the returned path object has a name that begins at beginIndex till the element at endIndex - 1. In other words, beginInedx is inclusive of the name in that index and exclusive of the name in endIndex. Throws IllegalArguementException if begin index is >= number of elements or endIndex number of elements.

A

Path subPath(int beginIndex, int endIndex)

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

Removes redundant elements in path such as . (dot symbol that indicates current directory) and ..(double dot symbol that indicates parent directory)

A

Path normalize()

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

Resolves a path against the given path.

A

Path resolve(Path or String other)

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

Returns true if the given path is an absolute path; false if not.

A

Boolean isAbsolute()

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

Returns true if this Path object starts with the given path, or false if not.

A

Path startsWith(String or Path path)

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

Returns the absolute path

A

Path toAbsolutePath()

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

Returns the URI from the path

A

URI toUri()

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

Returns an absolute path, but also normalizes it. Also resolves symbolic links. Unlike other methods, throws exception if target does not exist in filesystem.

A

toRealPath()

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

Checks equality of two path objects, returns true if equal, false if not.

A

equals()

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

Returns 0 if both paths are equal, a positive integer if this path is lexographically greater than the parameter path, and a negative integer if it is lexographically less.

A

compareTo()

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

Not actually part of the path interface, but the easiest way to get an actual path object.

A

Paths.get(String string)