Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.File;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.stream.Stream;

public class Main {

    public static void main(String[] args) {
        final String dir = "E:\\Java_Dev\\";
        final File file = Paths.get(dir).toFile();
        File[] files = file.listFiles();
        Arrays.sort(files, (f1, f2) -> {
            if (f1.isDirectory() != f2.isDirectory()) {
                if (f1.isDirectory()) {
                    return -1;
                } else {
                    return 1;
                }
            } else {
                return f1.getName().toLowerCase().compareTo(f2.getName().toLowerCase());
            }
        });
        Stream.of(files).forEach(System.out::println);
    }
}