Question: Create a file using any word-processing program or text editor. Write an application that displays the files name, containing folder, size, and time of last

Create a file using any word-processing program or text editor. Write an application that displays the files name, containing folder, size, and time of last modification. Save the file as FileStatistics.java.

Import these:

import java.nio.file.*; import java.nio.file.attribute.*; import java.io.IOException;

You must create a file on your system in the directory listed below. When I run your program it should find this file.

Path file = Paths.get("c:\\Temp\\Test1\\java\\test1.txt");

Use BasicFileAttributes

BasicFileAttributes attr = Files.readAttributes(file, BasicFileAttributes.class);

This program will read in an integer.

It will print out a last name from an array of 5 names.

IF the number is 999 the print out the file statistics (below)

IF the number is out of bounds then print a message that it is out of bounds.

If it is not a number, then print that error.

You must use:

Use:

catch(ArrayIndexOutOfBoundsException error)

catch(NumberFormatException error)

Sample Output:

Enter a number, and I will display a name g Not a number! Enter a number, and I will display a name 2 Name is Jones

Enter a number, and I will display a name 7 Index is out of bounds

Enter a number, and I will display a name

999

Print out the following information about the file:

Path is c:\Temp\Test1\java\test1.txt File name is test1.txt Folder name is java File's size is 10 File's creation time is 2014-04-08T23:22:29.695713Z

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!