-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain
More file actions
37 lines (29 loc) · 1009 Bytes
/
main
File metadata and controls
37 lines (29 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package LastTimeModified;
import java.io.File;
import java.util.Date;
import java.util.Scanner;
/**
* This program prints out the last modified date and time on a specified file.
*
* @author Christopher Flowers
* @version 10-1-2017
*
*/
public class ModifiedLastTime {
public static void main(String[] args) {
//creates a scanner for user input
Scanner scan = new Scanner(System.in);
//Prompt the user for a file location
System.out.println("Please type the location of the file you are trying to check the last modified time for...");
//Store the location into a variable
String fileName = scan.nextLine();
//assigns the file location to an object file
File file = new File(fileName);
//saves the date into its own Date variable
Date date = new Date(file.lastModified());
//display the last modified time on the specified file
System.out.println("\nThe file was last modified on: " + date + "\n");
//closer the scanner
scan.close();
}
}