In Java, there are several packages and API’s to perform a lot of different functions. One such package is java.nio.file. This package contains various methods which provide support for files. A package is java.nio.file.attribute, which can be used to access the attributes of the files specified in the path object.
So basically we are using the above mentioned two packages to access the attributes of files.
java.nio.file: This package is used to access FileSystem class and uses the inbuilt method “getpath()” helpful to get the path object.
java.nio.file.attribute: This package contains a lot of classes with predefined methods to read and access the attributes of a file. Firstly getFileAttributeView() method is used to get the files attributes and then readAttributes() method is used to get the attributes of the file. Then finally several methods of the class “BasicFileAttributes” are used to display various attributes of the file.
Below shows the basic implementation of these methods to display all the attributes of the file.
Please Login to comment...