Question: Create a file using any word - processing program or text editor. Write an application called FileStatistics that prompts the user for the filename and
Create a file using any wordprocessing program or text editor. Write an application called FileStatistics that prompts the user for the filename and displays the files path, name, folder, size, and time of last modification.
The default file path for your project directory is
An example of the program is shown below:
Enter file name example.txt Path is exampletxt File name is example.txt Folder name is workspace File's size is File's creation time is T::Z
Task : Create the FileStatistics class.
Task : The FileStatistics class displays the correct statistics on the provided file.
import java.nio.file.;
import java.nio.file.attribute.;
import java.ioIOException;
public class FileStatistics
public static void mainString args
Path filePath Paths.getFileStatisticsfile.txt;
try
BasicFileAttributes attr Files.readAttributesfilePath BasicFileAttributes.class;
System.out.println;
System.out.printlnFile Information";
System.out.println;
System.out.printlnName: filePath.getFileNametoString;
System.out.printlnSize: attr.size bytes";
System.out.printlnLast Modified: attr.lastModifiedTime;
System.out.println;
catch IOException error
System.out.printlnIO Exception: error.getMessage;
This is what I have Task works but I cant figure out Task
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
