Check out example codes for "check folder for files java". It will help you in understanding the concepts better.

Code Example 1

public void listFilesForFolder(final File folder) {
    for (final File fileEntry : folder.listFiles()) {
        if (fileEntry.isDirectory()) {
        } else {

final File folder = new File("/home/you/Desktop");

Code Example 2

File file = new File(path);

boolean exists =      file.exists();      // Check if the file exists
boolean isDirectory = file.isDirectory(); // Check if it's a directory
boolean isFile =      file.isFile();      // Check if it's a regular file

Learn ReactJs, React Native from