Chapter 9: NIO 2 Flashcards
can be used to get the operating system-dependent file separator from the JVM.
System.getProperty(“path.separator”)
optional arguments in NIO.2,If provided, symbolic links when encountered will not be traversed. Useful for performing operations on symbolic links themselves rather than their target.
NOFOLLOW_LINKS
optional arguments in NIO.2, If provided, symbolic links when encountered will be traversed.
FOLLOW_LINKS
optional arguments in NIO.2, If provided, all metadata about a file will be copied with it.
COPY_ATTRIBUTES
optional arguments in NIO.2, If provided and the target file exists, it will be replaced; otherwise, if it is not provided, an exception will be thrown if the file already exists.
REPLACE_EXISTING
optional arguments in NIO.2, The operation is performed in an atomic manner within the file system, ensuring that any process using the file sees only a complete record. Method using it may throw an exception if the feature is unsupported by the file system.
ATOMIC_MOVE
Path method, returns a String representation of the entire path.
Path.toString()
Path method, retrieve the number of elements in the path
Path.getNameCount() int
Path method, retrieve a reference to each element,
Path.getName(int i) - returns Path
Path method, returns a Path instance representing the filename, which is the farthest element from the root
Path.getFileName - returns Path
Path method, returns a Path instance representing the parent path or null if there is no such parent
Path.getParent() - returns Path
Path method, returns the root element for the Path object or null if the Path object is relative.
Path.getRoot() - returns Path
Path method, returns true if the path the object references is absolute and false if the path the object references is relative.
isAbsolute()
Path method, converts a relative Path object to an absolute Path object by joining it to the current working directory
toAbsolutePath()
Path method, returns a relative subpath of the Path object
Path.subpath(int, int) - returns Path,
Inclusive beginning index, exclusive end index
Path method, for constructing the relative path from one Path object to another.
Path.relativize(path2) - result is path of path2 in relation to this path.
Path method, for method for creating a new Path by joining an existing path to the current path.
Path.resolve(Path 2)