Results 1 to 1 of 1
-
How to get the last modified date of a file from a java program
This example code compares the last modified date of two files and show to the console.
Java Code:import java.io.File; public class lastModified { public static void main(String[] args) { String s1 = "c:\\file1.txt"; String s2 = "c:\\file2.txt"; File f1 = new File(s1); File f2 = new File(s2); if (f1.lastModified() < f2.lastModified()) { System.out.println(s1 + " is older than " + s2); System.out.println(f1.lastModified()); System.out.println(f2.lastModified()); } else { System.out.println(s2 + " is older than " + s1); } } }
Similar Threads
-
writing to a excel file from java program
By priyankabhar in forum New To JavaReplies: 7Last Post: 06-04-2013, 01:00 PM -
How to change the date of modification of a file
By Java Tip in forum java.ioReplies: 0Last Post: 04-05-2008, 10:10 AM -
Checking of file was modified on the server
By Java Tip in forum Java TipReplies: 0Last Post: 03-02-2008, 07:18 PM -
How to find file created date.....
By roshithmca in forum Advanced JavaReplies: 1Last Post: 02-18-2008, 09:48 AM -
Poblem in Compiling a c++ file from a java program...
By Amit Kr. Mishra in forum New To JavaReplies: 0Last Post: 11-06-2007, 10:41 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks