Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ / Program describes two files / / prompts user to see file statistics / / tells which one is newer and which one is
Program describes two files
prompts user to see file statistics
tells which one is newer and which one is larger
Note change path for data files if necessary on your computer
import java.nio.file.;
import java.nio.file.attribute.;
import java.ioIOException;
import java.util.;
public class DebugEleven
public static void mainString args
Scanner kb new ScannerSystemin;
String choice;
Path file
Paths.gethomentuserworkspaceDebugDatatxt;
Path file
Paths.gethomentuserworkspaceDebugDatatxt;
try
BasicFileAttributes attr
Files.readAttributesfile BasicFileAttributes.class;
System.out.printlnDo you want to see statistics for first file?";
System.out.printY or N ;
choice kbnextLine;
ifchoiceequalsY
System.out.printlnFile: filegetFileName;
System.out.printlnCreation time attrcreationTime;
System.out.printlnLast modified time attrlastModifiedTime;
System.out.printlnSize attrsize;
BasicFileAttributes attr
Files.readAttributesfile BasicFileAttributes.class;
System.out.printlnDo you want to see statistics for second file?";
System.out.printY or N ;
choice kbnextLine;
ifchoiceequalsY
System.out.println
File: filegetFileName;
System.out.printlnCreation time attrcreationTime;
System.out.printlnLast modified time attrlastModifiedTime;
System.out.printlnSize attrsize;
ifattrcreationTimecompareToattrcreationTime;
System.out.println
filegetFileName
was created earlier";
else
System.out.println
filegetFileName
was not created earlier";
ifattrsize attrsize
System.out.printlnfilegetFileName is larger ;
else
System.out.printlnfilegetFileName is not larger";
catchIOException e
System.out.printlnIO Exception";
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started