package Test;

import java.io.*;

import java.util.*;
 
public class GetDirectoryAndFileModifiedTime{
 
  public static void main(String[] args) throws IOException{
    BufferedReader in = new BufferedReader(new 
                          InputStreamReader(System.in));
    System.out.println("Enter file or directory name in proper format to get the modification date and time : ");
    File filename = new File(in.readLine());
 
    if (filename.isDirectory()){
 
      if (filename.exists()){
 
       long t = filename.lastModified();
 
       System.out.println("Directory name : " + filename.getName());
        System.out.println("Directory modification date and time : " + new Date(t)); 
     }
   
   else{
    
    System.out.println("Directory not found!");
 
        System.exit(0);
    
  }
   
 }
  
  else{
 
      if (filename.exists()){
 
       long t = filename.lastModified();
  
      System.out.println("File name : " + filename.getName());
        System.out.println("File 
                    modification date and time : " + new Date(t));
 
     }
  else{
    
    System.out.println("File not found!");
 
       System.exit(0);
   
   }
   
 }
  
}
 
}