www.webdeveloper.com
Results 1 to 3 of 3

Thread: Copy folder based on latest date

  1. #1
    Join Date
    Apr 2006
    Posts
    29

    Copy folder based on latest date

    Hi,

    Can anybody send me the java code to do following:

    - A directory containing sub-folders with different name and date
    - To copy the folder having the most recent date from the directory.

    Thanks in advance.

    Pankaj

  2. #2
    Join Date
    Jun 2009
    Posts
    98
    Use File listFiles() and a comparator to sort your array by last mod date.
    Apache Commons IO package has LastModifiedFileComparator that you can also use.

    listFiles() example to help get you in the right direction:
    PHP Code:
    public class FileWork 
    {
      public static 
    void main(String[] a
      {
        
    File myFile = new File("C:" File.separator);
        for(
    File smyFile.listFiles())
        {
          
    System.out.println(s);
        }
      }


  3. #3
    Join Date
    Apr 2006
    Posts
    29
    Thanks it helped.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles