0

i wish to read file + folder+ shortcut on desktop with its created date and modified/last access date...so what changes should i made

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class read {

public static void main(String[] args) {
    List<File> fileList =new ArrayList();
    final File folder = new File("C:\\Users\\ROSH\\Desktop");
    new read().listFilesForFolder(folder, fileList);
}

public void listFilesForFolder(final File folder,List<File> fileList) {
    File[] filesInFolder = folder.listFiles();

    if (filesInFolder != null) {
        for (final File fileEntry : filesInFolder) {
            if (fileEntry.isDirectory()) {
                System.out.println("DIR : "+fileEntry.getName());
                listFilesForFolder(fileEntry,fileList);
            } else {
                System.out.println("FILE : "+fileEntry.getName());
                fileList.add(fileEntry);
            }
        }
    }
}
crush
  • 16,713
  • 9
  • 59
  • 100
Roshan Bagdiya
  • 2,048
  • 21
  • 41
  • 1
    So what is the problem? Your program looks OK. – Mad Physicist Feb 04 '14 at 16:29
  • Welcome to StackOverflow, Roshan. Can you help us out by defining a specific problem with your code above? What excepted output do you wish to receive? What output are you receiving instead? – crush Feb 04 '14 at 16:30
  • @MadPhysicist sir i want the creted date and last access/modified date of that files – Roshan Bagdiya Feb 04 '14 at 16:33
  • possible duplicate of [Determine file creation date in Java](http://stackoverflow.com/questions/2723838/determine-file-creation-date-in-java) – crush Feb 04 '14 at 16:36
  • @crush i am getting all the files of desktop as output(even though the files are in folder) and also the created date and access date of that file, and my main problem statement is Write a program to identify the least used icons/files/folders on the desktop and move them to temp folder created in Documents. – Roshan Bagdiya Feb 04 '14 at 16:37
  • 2
    @Roshan, isn't that what you are trying to do? You should really clarify your expected output in the question. – Mad Physicist Feb 04 '14 at 16:37

0 Answers0