Java Folder Read getFiles(String path)

Here you can find the source of getFiles(String path)

Description

get Files

License

Open Source License

Declaration

public static File[] getFiles(String path) 

Method Source Code

//package com.java2s;

import java.io.File;

import java.util.Arrays;
import java.util.Comparator;

public class Main {

    public static File[] getFiles(String path) {
        File file = new File(path);
        // get the folder list   
        File[] array = file.listFiles();
        Arrays.sort(array, new Comparator<File>() {
            @Override/*from w  ww .  j  a  va  2s .  c  o  m*/
            public int compare(File file, File newFile) {
                if (file.lastModified() < newFile.lastModified()) {
                    return 1;
                } else if (file.lastModified() == newFile.lastModified()) {
                    return 0;
                } else {
                    return -1;
                }
            }
        });
        return array;
    }
}

Related

  1. getFiles(String directoryPath)
  2. getFiles(String dirName, int number)
  3. getFiles(String folderName, String prefix)
  4. getFiles(String parent)
  5. getFiles(String path)
  6. getFiles(String path)
  7. getFiles(String path)
  8. getFiles(String PATH)
  9. getFiles(String path)