import java.io.*; public class ComparingFileDates { static String compare; static long modify1; static long modify2; static void comparing(){ //String compare; if (modify1 == modify2) compare = " are created at the same time along with"; else if (modify1 < modify2) compare = " file is older than "; else compare = "file is newer than"; } public static void main(String[] args) { File file1 = new File(args[0]); File file2 = new File(args[1]); // Get the timestamp from file 1 modify1 = file1.lastModified(); modify2 = file2.lastModified(); comparing(); System.out.println(file1 + compare + ' ' + file2); } }