In: Computer Science
JAVA program that reads a text file into RAM efficiently, takes a regular expression from the user, and then prints every line that matches the expression :
Path is an interface which is introduced in Java NIO file package during Java version 7,and is the representation of location in particular file system.As path interface is in Java NIO package so it get its qualified name as java.nio.file.Path. In order to get the instance of Path we can use static method of java.nio.file.Paths class get().This method converts a path string, or a sequence of strings that when joined form a path string, to a Path instance.This method also throws runtime InvalidPathException if the arguments passed contains illegal characters.
Methods of Path Interface:
getFileName() − Returns the file system that created this object.
getName() − Returns a name element of this path as a Path object.
getNameCount() − Returns the number of name elements in the path.
subpath() − Returns a relative Path that is a subsequence of the name elements of this path.
getRoot() − Returns the root component of this path as a Path object, or null if this path does not have a root component.
toAbsolutePath() − Returns a Path object representing the absolute path of this path.
toRealPath() − Returns the real path of an existing file.
toFile() − Returns a File object representing this path.