Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File List by Date/Time Created

Status
Not open for further replies.

SGM

Technical User
Jun 12, 2001
7
0
0
US
I have a program that stores a list of the files in a directory to an array. However, it is created alphabetically by file name. Because of the application, I need to process these files in the order they came in. What is the best method of creating the array based upon the the file date/time stamp rather than name (I'm using the file.list() method)?

Thanks,
Steve
 

well, File.list() just returns file names in a String[], no time info included. i think u should sort them based on time by yourself. take a look at the following piece:

String[] FileName = File.list();

for (int i=0; i<FileName.length; i++)
{
File fileObj = new File(FileName);
long lastModifiedTime = fileObj.lastModified();

...... //your sorting here
}

hopefully it can be of any help.

 
Thanks, WhiteSox, it's just what I needed!

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top